demarches-normaliennes/app/validators/password_complexity_validator.rb

10 lines
295 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class PasswordComplexityValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
2024-09-17 10:59:58 +02:00
if value.present? && ZxcvbnService.complexity(value) < PASSWORD_COMPLEXITY_FOR_ADMIN
record.errors.add(attribute, :not_strong)
end
end
end