Class: Hermod::Validators::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/hermod/validators/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



6
7
8
# File 'lib/hermod/validators/base.rb', line 6

def attributes
  @attributes
end

#valueObject (readonly)

Returns the value of attribute value.



6
7
8
# File 'lib/hermod/validators/base.rb', line 6

def value
  @value
end

Instance Method Details

#valid?(value, attributes) ⇒ Boolean

Public: Runs the test for the validator returning true if it passes and raising if it fails

Raises a Hermod::InvalidInputError if the test fails Returns true if it succeeds

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/hermod/validators/base.rb', line 13

def valid?(value, attributes)
  @value, @attributes = value, attributes
  !!test || raise(InvalidInputError, message)
end