demarches-normaliennes/app/validators/password_complexity_validator.rb
Christophe Robillard 3428c58b9e extract password complexity validator
for user and superadmin
2020-12-15 16:26:09 +01:00

7 lines
263 B
Ruby

class PasswordComplexityValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if value.present? && ZxcvbnService.new(value).score < PASSWORD_COMPLEXITY_FOR_ADMIN
record.errors.add(attribute, :not_strong)
end
end
end