View Source PasswordValidator.Validators.LengthValidator (Password Validator v0.5.0)
Validates a password by checking the length of the password.
Link to this section Summary
Functions
Validate the password by checking the length
Link to this section Functions
Validate the password by checking the length
Example config (min 5 characters, max 9 characters):
[
length: [
min: 5,
max: 9,
]
]
examples
Examples
iex> LengthValidator.validate("simple2", [length: [min: 3]])
:ok
iex> LengthValidator.validate("too_short", [length: [min: 10]])
{:error, [{"String is too short. Only 9 characters instead of 10",
validator: PasswordValidator.Validators.LengthValidator, error_type: :too_short}]}
iex> LengthValidator.validate("too_long", [length: [min: 3, max: 6]])
{:error, [{"String is too long. 8 but maximum is 6",
validator: PasswordValidator.Validators.LengthValidator, error_type: :too_long}]}