Sha256: 73e3b9c1d90a7cf555b8bfa1f81811b78ed36eab6655b35fb9a4187fc490133b

Contents?: true

Size: 237 Bytes

Versions: 5

Compression:

Stored size: 237 Bytes

Contents

class SlugValidator < ActiveModel::EachValidator

  def validate_each(record, attribute, value)
    unless value =~ /^[a-z0-9-]+$/
      record.errors[attribute] << (options[:message] || I18n.t('errors.messages.slug'))
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
flash_validators-3.0.1 lib/flash_validators/validators/slug_validator.rb
flash_validators-3.0.0 lib/flash_validators/validators/slug_validator.rb
flash_validators-1.1.0 lib/flash_validators/validators/slug_validator.rb
flash_validators-1.0.0 lib/flash_validators/validators/slug_validator.rb
flash_validators-0.0.1 lib/flash_validators/validators/slug_validator.rb