PreventBlankificationValidator
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
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
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request