Sha256: 25e5dd571b40e5a8f05cf717165f0cf8855734c59b7be40f5ead3b82c65597c6
Contents?: true
Size: 535 Bytes
Versions: 10
Compression:
Stored size: 535 Bytes
Contents
# frozen_string_literal: true class PasswordValidator < BaseValidator REGEXP ||= { strong: /\A(?=.{4,255})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[[:^alnum:]])/x, weak: /^[A-Za-z0-9.,<>:;!@#$%^&*?_~-]{1,255}$/ }.freeze def validate_each(record, attribute, value) assert_valid_strength! super end private def assert_valid_strength! assert_valid_option!(:strength, REGEXP.keys) end def strength options[:strength] || :weak end def valid_regexp? value.to_s =~ REGEXP[strength] end end
Version data entries
10 entries across 10 versions & 1 rubygems