Sha256: e0be90601a7d1e694b3824b0184bc19aafd639e2fbc90a806711cca19e186728

Contents?: true

Size: 232 Bytes

Versions: 6

Compression:

Stored size: 232 Bytes

Contents

class SlugValidator < ActiveModel::EachValidator
  def validate_each(object, attribute, value)
    unless value =~ /^[a-z0-9-]+$/
      object.errors[attribute] << (options[:message] || "is not formatted properly")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
drexed-validators-0.0.13 app/validators/slug_validator.rb
drexed-validators-0.0.12 app/validators/slug_validator.rb
drexed-validators-0.0.11 app/validators/slug_validator.rb
drexed-validators-0.0.10 app/validators/slug_validator.rb
drexed-validators-0.0.9 app/validators/slug_validator.rb
drexed-validators-0.0.7 app/validators/slug_validator.rb