checkPassword
Validates a password against length and (optionally) symbol
requirements.
Returns: string \| boolean
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
password | string | required | - | The password to check. |
minLength | number | optional | 8 | Minimum allowed length. Defaults to 8. |
maxLength | number | optional | 20 | Maximum allowed length. Defaults to 20. |
includeSymbolsCheck | boolean | optional | false | Whether the password must contain a symbol. Defaults to false. |
userSymbolRegex | `string \ | RegExp` | optional | '' |
Usage
Example: Validate Password
const isStrongPassword = nfsfu234FormValidation.checkPassword('StrongP@ssword123');
console.log("isStrongPassword: ", isStrongPassword); // true or error messageExample: Validate Password with Symbol Check
const isStrongPassword = nfsfu234FormValidation.checkPassword('StrongP@ssword123', true);
console.log("isStrongPassword: ", isStrongPassword); // true or error messageExample: Validate Password with Symbol Check With Custom Regex
const isStrongPasswordWithSymbols = nfsfu234FormValidation.checkPassword('StrongP@ssword123', true, 8, 20, '[!@#$%^&*()]');
console.log("isStrongPasswordWithSymbols: ", isStrongPasswordWithSymbols); // true or error messageLast updated on