Class: SlugValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- SlugValidator
- Defined in:
- lib/slug_validator.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(object, attribute, value) ⇒ Object
2 3 4 5 6 |
# File 'lib/slug_validator.rb', line 2 def validate_each(object, attribute, value) unless value =~ /^\D(\w*-*)*$/ object.errors[attribute] << ([:message] || "is not formatted properly (should contain only letters, digits, dashes and underscores and can't start with digit)") end end |