Class: ActiveModel::Validations::StoreModelValidator
- Inherits:
-
EachValidator
- Object
- EachValidator
- ActiveModel::Validations::StoreModelValidator
- Defined in:
- lib/active_model/validations/store_model_validator.rb
Overview
StoreModelValidator
is a subclass of ActiveModel::EachValidator for checking StoreModel::Model attributes.
Instance Method Summary collapse
-
#validate_each(record, attribute, value) ⇒ Object
Validates json attribute using the configured strategy or invalidates array attribute when at least one element is invalid.
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
Validates json attribute using the configured strategy or invalidates array attribute when at least one element is invalid.
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/active_model/validations/store_model_validator.rb', line 17 def validate_each(record, attribute, value) if value.nil? record.errors.add(attribute, :blank) return end case record.type_for_attribute(attribute).type when :json, :polymorphic call_json_strategy(record, attribute, value) when :array, :polymorphic_array call_array_strategy(record, attribute, value) end end |