PasswordValidator.Validators.CharacterSetValidator (Password Validator v0.5.2)

View Source

Validates a password by checking the different types of characters contained within.

Summary

Functions

do_validate_character_set(character_set, count, config)

@spec do_validate_character_set(atom(), integer(), list()) ::
  :ok | {:error, String.t()}

interpret_additional_info(arg, custom_messages)

validate(string, opts)

Example config [ character_set: [

# Require at least 1 upper case letter
upper_case: [1, :infinity],
# Require at least 1 lower case letter
lower_case: 1,
# Require at least 1 number
numbers: 1,
# Require exactly 0 special characters
special: [0, 0],
# Specify which special characters are allowed (default is :all)
allowed_special_characters: "!@#$%^&*()",

] ]

validate_character_set(atom, map, config)

@spec validate_character_set(
  atom(),
  map(),
  PasswordValidator.Validators.CharacterSetValidator.Config.t()
) :: {atom(), :ok} | {atom(), {:error, String.t()}}