class Hermod::Validators::Base
Public Instance Methods
valid?(value, attributes)
click to toggle source
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
# File lib/hermod/validators/base.rb, line 11 def valid?(value, attributes) !!test(value, attributes) || raise(InvalidInputError, message(value, attributes)) end
Private Instance Methods
message(value, attributes)
click to toggle source
Private: override in subclasses to provide a more useful error message
Returns a string
# File lib/hermod/validators/base.rb, line 28 def message(value, attributes) "is invalid" end
test(value, attributes)
click to toggle source
Private: override in subclasses to implement the logic for that validator
Returns a boolean
# File lib/hermod/validators/base.rb, line 21 def test(value, attributes) raise NotImplementedError end