Module: Waw::Validation::ComparisonValidations::Methods

Included in:
Waw::Validation::ComparisonValidations
Defined in:
lib/waw/validation/comparison_validations.rb

Instance Method Summary collapse

Instance Method Details

#<(value) ⇒ Object

Builds a validator that verifies that the length is less than a specified value



20
21
22
# File 'lib/waw/validation/comparison_validations.rb', line 20

def <(value)
  Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| val.respond_to?(:<) and val < value} }}
end

#<=(value) ⇒ Object

Builds a validator that verifies that the length is less-or-equal to a specified value



26
27
28
# File 'lib/waw/validation/comparison_validations.rb', line 26

def <=(value)
  Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| val.respond_to?(:<=) and val <= value} }}
end

#==(value) ⇒ Object

Builds a validator that verifies that the length is equal to a specified value



32
33
34
# File 'lib/waw/validation/comparison_validations.rb', line 32

def ==(value)
  Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| val.respond_to?(:==) and val == value} }}
end

#>(value) ⇒ Object

Builds a validator that verifies that the length is greater than a specified value



8
9
10
# File 'lib/waw/validation/comparison_validations.rb', line 8

def >(value)
  Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| val.respond_to?(:>) and val > value} }}
end

#>=(value) ⇒ Object

Builds a validator that verifies that the length is greater-or-equal to a specified value



14
15
16
# File 'lib/waw/validation/comparison_validations.rb', line 14

def >=(value)
  Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| val.respond_to?(:>=) and val >= value} }}
end

#in(*values) ⇒ Object

Same as Waw::Validation.isin



37
38
39
# File 'lib/waw/validation/comparison_validations.rb', line 37

def in(*values)
  Waw::Validation.isin(*values)
end