Sha256: 602e5c52231f51cbd80e0b82b57d6041b4f78b697f0379dab83f191783d46b82

Contents?: true

Size: 251 Bytes

Versions: 5

Compression:

Stored size: 251 Bytes

Contents

class UsernameValidator < ActiveModel::EachValidator

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

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