Class: Assent::Validator
- Inherits:
-
Object
- Object
- Assent::Validator
- Defined in:
- lib/assent/validator.rb
Instance Method Summary collapse
- #errors ⇒ Object
- #errors_class ⇒ Object
-
#validate(input) ⇒ Object
This validate method will validate the input against the rules.
Methods included from Config
add, config, config_file, #initialize
Methods included from Options
Methods included from Field
Methods included from ValidationsSet
Instance Method Details
#errors ⇒ Object
17 18 19 |
# File 'lib/assent/validator.rb', line 17 def errors errors_class.errors end |
#errors_class ⇒ Object
13 14 15 |
# File 'lib/assent/validator.rb', line 13 def errors_class @errors ||= Errors.new end |
#validate(input) ⇒ Object
This validate method will validate the input against the rules. At the end it returns true or false. If the errors are empty, it means the validation passed
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/assent/validator.rb', line 23 def validate(input) @@validations.each do |field, validations| value = input[field] value = input[field].to_s if value.nil? validate = Validate.new(field, value, validations, errors_class) validate.validate end errors.empty? end |