demarches-normaliennes/app/validators/password_complexity_validator.rb
2024-08-22 09:26:48 +02:00

9 lines
294 B
Ruby

# frozen_string_literal: true
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