2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-11-17 17:13:31 +01:00
|
|
|
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
|
2020-11-17 17:13:31 +01:00
|
|
|
record.errors.add(attribute, :not_strong)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|