Class: Escort::Validator
- Inherits:
-
Object
- Object
- Escort::Validator
- Defined in:
- lib/escort/validator.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(parser) ⇒ Validator
constructor
A new instance of Validator.
- #validate(options, validations) ⇒ Object
Constructor Details
#initialize(parser) ⇒ Validator
Returns a new instance of Validator.
11 12 13 |
# File 'lib/escort/validator.rb', line 11 def initialize(parser) @parser = parser end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
9 10 11 |
# File 'lib/escort/validator.rb', line 9 def parser @parser end |
Class Method Details
.for(parser) ⇒ Object
4 5 6 |
# File 'lib/escort/validator.rb', line 4 def for(parser) self.new(parser) end |
Instance Method Details
#validate(options, validations) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/escort/validator.rb', line 15 def validate(, validations) validations.each do |option, validations_array| if option_exists?(option) validate_option(option, , validations_array) else raise Escort::ClientError.new("Unable to create validation for '#{option}' as no such option was defined, maybe you misspelled it") end end end |