Class: Waw::Validation::NotValidator
- Defined in:
- lib/waw/validation/not_validator.rb
Instance Method Summary collapse
- #convert_and_validate(*values) ⇒ Object
-
#initialize(negated) ⇒ NotValidator
constructor
A new instance of NotValidator.
- #validate(*values) ⇒ Object
Methods inherited from Validator
Methods included from Helpers
#all_missing?, #any_missing?, #argument_safe, #error, #is_missing?, #missings_to_nil, #no_missing?, #to_validator
Constructor Details
#initialize(negated) ⇒ NotValidator
Returns a new instance of NotValidator.
5 6 7 |
# File 'lib/waw/validation/not_validator.rb', line 5 def initialize(negated) @negated = negated end |
Instance Method Details
#convert_and_validate(*values) ⇒ Object
13 14 15 16 |
# File 'lib/waw/validation/not_validator.rb', line 13 def convert_and_validate(*values) ok, converted = @negated.convert_and_validate(*values) ok ? [false, values] : [true, converted] end |
#validate(*values) ⇒ Object
9 10 11 |
# File 'lib/waw/validation/not_validator.rb', line 9 def validate(*values) not(@negated.validate(*values)) end |