Class: StringAttributeValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- StringAttributeValidator
- Defined in:
- lib/trax/validators/string_attribute_validator.rb
Overview
validates each json property and bubbles up any errors also throws a generic can not be blank error, in the event that a hash is not provided
Instance Method Summary collapse
Instance Method Details
#validate_each(object, attribute, value) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/trax/validators/string_attribute_validator.rb', line 5 def validate_each(object, attribute, value) string_attribute = value.class unless value.valid? if value.is_a?(string_attribute) value.errors..each_pair do |k,v| v.flatten.join(", ") if v.is_a?(Array) object.errors.add("#{attribute}.#{k}", v) end end end end |