Class: Amalgam::Validator::Slug
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Amalgam::Validator::Slug
- Defined in:
- lib/amalgam/validators/slug.rb
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/amalgam/validators/slug.rb', line 3 def validate(record) slug_field = [:field] || :slug unless record.send(slug_field) =~ /\A[0-9a-z\-_]+\z/ record.errors.add(attribute, :invalid, ) end end |