Password Validator v0.4.0 PasswordValidator.Validators.LengthValidator View Source

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

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"]}

iex> LengthValidator.validate("too_long", [length: [min: 3, max: 6]])
{:error, ["String is too long. 8 but maximum is 6"]}