Class: FolderNameConventionValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- FolderNameConventionValidator
- Defined in:
- app/validators/folder_name_convention_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, field, value) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'app/validators/folder_name_convention_validator.rb', line 4 def validate_each(record, field, value) unless value.nil? unless value.match?(/^[[:alnum:]\s]+$/) record.errors.add(field, 'is not alphanumeric (letters, numbers, or spaces)') end record.errors.add(field, 'contains illegal characters') if value.match?(/[\n\t\f\b\r]/) record.errors.add(field, 'contains illegal characters') unless value.ascii_only? end end |