Class: Hermod::Validators::Base
- Inherits:
-
Object
- Object
- Hermod::Validators::Base
- Defined in:
- lib/hermod/validators/base.rb
Direct Known Subclasses
AllowedValues, Attributes, NonNegative, NonZero, Range, RegularExpression, TypeChecker, ValuePresence, WholeUnits
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#valid?(value, attributes) ⇒ Boolean
Public: Runs the test for the validator returning true if it passes and raising if it fails.
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
6 7 8 |
# File 'lib/hermod/validators/base.rb', line 6 def attributes @attributes end |
#value ⇒ Object (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
13 14 15 16 |
# File 'lib/hermod/validators/base.rb', line 13 def valid?(value, attributes) @value, @attributes = value, attributes !!test || raise(InvalidInputError, ) end |