Module: Waw::Validation::SizeValidations::Methods
- Included in:
- Waw::Validation::SizeValidations
- Defined in:
- lib/waw/validation/size_validations.rb
Instance Method Summary collapse
-
#<(value) ⇒ Object
Builds a validator that verifies that the length is less than a specified value.
-
#<=(value) ⇒ Object
Builds a validator that verifies that the length is less-or-equal to a specified value.
-
#==(value) ⇒ Object
Builds a validator that verifies that the length is equal to a specified value.
-
#>(value) ⇒ Object
Builds a validator that verifies that the length is greater than a specified value.
-
#>=(value) ⇒ Object
Builds a validator that verifies that the length is greater-or-equal to a specified value.
-
#has_size?(val) ⇒ Boolean
Checks that it has a size.
Instance Method Details
#<(value) ⇒ Object
Builds a validator that verifies that the length is less than a specified value
24 25 26 |
# File 'lib/waw/validation/size_validations.rb', line 24 def <(value) Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| has_size?(val) and (val.size < value)} }} end |
#<=(value) ⇒ Object
Builds a validator that verifies that the length is less-or-equal to a specified value
30 31 32 |
# File 'lib/waw/validation/size_validations.rb', line 30 def <=(value) Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| has_size?(val) and (val.size <= value)} }} end |
#==(value) ⇒ Object
Builds a validator that verifies that the length is equal to a specified value
36 37 38 |
# File 'lib/waw/validation/size_validations.rb', line 36 def ==(value) Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| has_size?(val) and (val.size == value)} }} end |
#>(value) ⇒ Object
Builds a validator that verifies that the length is greater than a specified value
12 13 14 |
# File 'lib/waw/validation/size_validations.rb', line 12 def >(value) Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| has_size?(val) and (val.size > value)} }} end |
#>=(value) ⇒ Object
Builds a validator that verifies that the length is greater-or-equal to a specified value
18 19 20 |
# File 'lib/waw/validation/size_validations.rb', line 18 def >=(value) Validator.new {|*vals| Validation.argument_safe{ vals.all?{|val| has_size?(val) and (val.size >= value)} }} end |
#has_size?(val) ⇒ Boolean
Checks that it has a size
8 |
# File 'lib/waw/validation/size_validations.rb', line 8 def has_size?(val) val.respond_to?(:size) end |