Sha256: 9fff8c14d7389aba2bd79bb510b500a8add142a26ebb36cb821b9706884e7e87

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# PreventBlankificationValidator

[![Build Status](https://travis-ci.org/gewo/prevent_blankification_validator.png)](https://travis-ci.org/gewo/prevent_blankification_validator/)

Rails 3 Validator, that prevents attributes from being changed to a blank value
once they're present.

## Installation

Add this line to your application's Gemfile:

    gem 'prevent_blankification_validator'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install prevent_blankification_validator

## Usage

```ruby
class MyModel
  validates :value, prevent_blankification: true
end

model.value = 'present'
model.save             # => true

model.value = ''
model.valid?           # => false

model.value = "\r    \n  "
model.valid?           # => false

model.value = nil
model.valid?           # => false

model.value = 'present as well'
model.valid?           # => true

```

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prevent_blankification_validator-0.0.1 README.md