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)
|
|
|
|
if value.present? && ZxcvbnService.new(value).score < PASSWORD_COMPLEXITY_FOR_ADMIN
|
|
|
|
record.errors.add(attribute, :not_strong)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|