class CustomAttributes::Unbounded
This class is only to be extended by types that need length validation
Public Instance Methods
validate_single_value(custom_field, value, customizable = nil)
click to toggle source
Calls superclass method
CustomAttributes::FieldType#validate_single_value
# File lib/custom_attributes/field_types/unbounded.rb, line 4 def validate_single_value(custom_field, value, customizable = nil) errs = super value = value.to_s if custom_field.min_length && value.length < custom_field.min_length errs << ::I18n.t('activerecord.errors.messages.too_short', count: custom_field.min_length) end if custom_field.max_length && custom_field.max_length > 0 && value.length > custom_field.max_length errs << ::I18n.t('activerecord.errors.messages.too_long', count: custom_field.max_length) end errs end