Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 2.6 KB

requirements-validation.md

File metadata and controls

47 lines (35 loc) · 2.6 KB

Requirements validation

Options

You can use the Rollerworks\Component\PasswordStrength\Validator\Constraints\PasswordRequirements constraint with the following options:

Option Type Description
minLength int Minimum length of the password, should be at least 6 (or 8 for better security)
requireLetters bool Require that the password should at least contain one letter (default true)
requireCaseDiff bool Require that the password should at least contain one lowercase and one uppercase letter (default false)
requireNumbers bool Require that the password should at least contain one number (default false)
requireSpecialCharacter bool Require that the password should at least contain one non lateral or numerical character like @ (default false)

Note: Validation is performed with respect to international encodings, so the international character will be treated as 9 in ASCII.

Translations

You can customize the validation error messages with the following:

Message Default (en)
tooShortMessage 'Your password must be at least {{length}} characters long.'
missingLettersMessage 'Your password must include at least one letter.'
requireCaseDiffMessage 'Your password must include both upper and lower case letters.'
missingNumbersMessage 'Your password must include at least one number.'
missingSpecialCharacterMessage 'Your password must contain at least one special character.'

Annotations

If you are using annotations for validation, include the constraints namespace:

use Rollerworks\Component\PasswordStrength\Validator\Constraints as RollerworksPassword;

and then add the PasswordRequirements constraint to the relevant field:

/**
 * @RollerworksPassword\PasswordRequirements(requireLetters=true, requireNumbers=true, requireCaseDiff=true)
 */
protected $password;