class Assent::Validator

Public Instance Methods

errors() click to toggle source
# File lib/assent/validator.rb, line 17
def errors
  errors_class.errors
end
errors_class() click to toggle source
# File lib/assent/validator.rb, line 13
def errors_class
  @errors ||= Errors.new
end
validate(input) click to toggle source

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

# 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