Class: HasValidatedAttributes::SafeTextValidator

Inherits:
ActiveModel::EachValidator
  • Object
show all
Defined in:
lib/has_validated_attributes.rb

Instance Method Summary collapse

Instance Method Details

#validate_each(record, attribute, value) ⇒ Object



27
28
29
# File 'lib/has_validated_attributes.rb', line 27

def validate_each(record, attribute, value)
  record.errors[attribute] << NO_CONTROL_CHARS_ERROR_MSG unless NO_CONTROL_CHARS_REGEX =~ value.to_s.gsub(/[\n\r\t]/, '')
end