Class: Waw::Validation::AndValidator
- Defined in:
- lib/waw/validation/and_validator.rb
Instance Method Summary collapse
-
#convert_and_validate(*values) ⇒ Object
Converts and validate.
-
#initialize(*validators) ⇒ AndValidator
constructor
Empty constructor that overrides the top one.
-
#validate(*values) ⇒ Object
Calls the block installed at initialization time.
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(*validators) ⇒ AndValidator
Empty constructor that overrides the top one
6 7 8 |
# File 'lib/waw/validation/and_validator.rb', line 6 def initialize(*validators) @validators = validators end |
Instance Method Details
#convert_and_validate(*values) ⇒ Object
Converts and validate
16 17 18 19 20 21 22 23 |
# File 'lib/waw/validation/and_validator.rb', line 16 def convert_and_validate(*values) initials = values @validators.each do |validator| ok, values = validator.convert_and_validate(*values) return [ok, initials] unless ok end [true, values] end |
#validate(*values) ⇒ Object
Calls the block installed at initialization time
11 12 13 |
# File 'lib/waw/validation/and_validator.rb', line 11 def validate(*values) @validators.all?{|validator| validator.validate(*values)} end |