module FlexValidations::Validation

@abstract Validation should define {#validate} and {#to_s} methods

Public Instance Methods

===(value) click to toggle source

@param [Object] Value to match

@return [Boolean]

@example

case 1
when odd
  puts "its odd number"
end
Calls superclass method
# File lib/flex_validations/validation.rb, line 37
def ===(value)
  validate(value).success? || super
end
to_proc() click to toggle source

@return [Proc]

@example

[1, 2, 3].select(&odd) #=> [1, 3]
# File lib/flex_validations/validation.rb, line 45
def to_proc
  proc { |value| validate(value).success? }
end
to_s() click to toggle source

@abstract Returns description of validation

@return [String]

# File lib/flex_validations/validation.rb, line 24
def to_s
  raise 'not implemented'
end
validate(value) click to toggle source

@abstract Do validation of value

@param value [Object] Value to be validated

@return [FlexValidations::Result]

@example

odd.validate(1).success? #=> true

@example

odd.validate(2).fail? #=> true
# File lib/flex_validations/validation.rb, line 17
def validate(value)
  raise 'not implemented'
end