Class: Waw::Validation::IntegerValidator
- Defined in:
- lib/waw/validation/integer_validator.rb
Instance Method Summary collapse
Methods inherited from Validator
#&, #===, #=~, #initialize, #not, #|
Methods included from Helpers
#all_missing?, #any_missing?, #argument_safe, #error, #is_missing?, #missings_to_nil, #no_missing?, #to_validator
Constructor Details
This class inherits a constructor from Waw::Validation::Validator
Instance Method Details
#convert_and_validate(*values) ⇒ Object
9 10 11 12 |
# File 'lib/waw/validation/integer_validator.rb', line 9 def convert_and_validate(*values) ok = values.all?{|v| Integer===v or (/^[+-]?\d+$/ =~ v.to_s.strip)} ok ? [true, values.collect{|v| v.to_s.strip.to_i}] : [false, values] end |
#validate(*values) ⇒ Object
5 6 7 |
# File 'lib/waw/validation/integer_validator.rb', line 5 def validate(*values) values.all?{|val| ::Integer===val} end |