Module: Shamu::Attributes::Validation::Overrides

Defined in:
lib/shamu/attributes/validation.rb

Overview

Overrides ActiveModel::Validation behavior to match Shamu validation behaviors.

Instance Method Summary collapse

Instance Method Details

#valid?Boolean

Returns true if there are no errors reported manually or through Validation#validate.

Returns:

  • (Boolean)

    true if there are no errors reported manually or through Validation#validate.



60
61
62
63
# File 'lib/shamu/attributes/validation.rb', line 60

def valid?
  validate unless validated?
  errors.empty?
end

#validateObject

Validate the attributes and expose any errors via #errors.



66
67
68
69
# File 'lib/shamu/attributes/validation.rb', line 66

def validate
  @validated = true
  run_validations!
end