Sha256: 824b8cee21341c8ee6c4531fe74cb38b6ad93c9f54e33846c8b2d1bd18f4ed76
Contents?: true
Size: 530 Bytes
Versions: 2
Compression:
Stored size: 530 Bytes
Contents
class PasswordValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless valid?(value, options) record.errors[attribute] << (options[:message] || I18n.t('errors.messages.password')) end end private def valid_format?(value, options) if options[:strict] value =~ /^(?=^.{6,18}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.*$/ else value =~ /^[a-z0-9!@#$%^&*_-]{6,18}$/ end end def valid?(value, options) valid_format?(value, options) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
flash_validators-3.0.1 | lib/flash_validators/validators/password_validator.rb |
flash_validators-3.0.0 | lib/flash_validators/validators/password_validator.rb |