Sha256: f0f660c9a5dfca759d610c84028dfba569fe624d4b9939bcced99c9bc92d428e
Contents?: true
Size: 512 Bytes
Versions: 9
Compression:
Stored size: 512 Bytes
Contents
module Tuning module Validations extend ActiveSupport::Concern class ComplexityValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if value !~ /\A(?=.*[a-z])(?=.*[A-Z])(?=.*[\d])(?=.*[\W\_]).{8,}*\z/ record.errors.add attribute, :too_easy end end end module ClassMethods def validates_complexity_of(*attr_names) validates_with ComplexityValidator, _merge_attributes(attr_names) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems