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.



64
65
66
67
# File 'lib/shamu/attributes/validation.rb', line 64

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

#validateObject

Validate the attributes and expose any errors via #errors.



70
71
72
73
# File 'lib/shamu/attributes/validation.rb', line 70

def validate
  @validated = true
  run_validations!
end