StateValidator
A custom validator for stateful attributes of ActiveRecord objects. It's work like an inclusion validation and it's need for you if you are use RailsAdmin, also for State Machine implementation with the transition_validator gem.
Installation
Add this line to your application's Gemfile:
gem 'state_validator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install state_validator
Usage
Place validator into your model:
validates :my_state_attribute, :state => true
Place enumeration of values:
def my_state_attribute_enum
['on', 'off']
end
If an attribute validation returns error then object.errors including message generated by I18n.t('errors.messages.inclusion').
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request