extract password complexity validator
for user and superadmin
This commit is contained in:
parent
15a395fbc7
commit
3428c58b9e
3 changed files with 9 additions and 14 deletions
7
app/validators/password_complexity_validator.rb
Normal file
7
app/validators/password_complexity_validator.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue