|
1 |
| -# deno-password-checker |
| 1 | +# Password Checker |
| 2 | + |
| 3 | +A Deno module to test if a password/string matches the preset criteria. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +`import { checkPassword } from "https://deno.land/x/password-checker/mods.ts";` |
| 8 | + |
| 9 | +## Parameters |
| 10 | + |
| 11 | +### Mandatory Parameters: |
| 12 | + |
| 13 | +- password: string |
| 14 | + |
| 15 | +### Optional Parameters: |
| 16 | + |
| 17 | +- minLen: number - To check the password against a minimum length. Defaults to 0 |
| 18 | + which disables the check. |
| 19 | +- maxLen: number - To check the password against a maximum length. Defaults to 0 |
| 20 | + which disables the check. |
| 21 | +- containsNum: boolean - To check if the password contains any numbers. Defaults |
| 22 | + to true and enables the check. |
| 23 | +- containsSpecialChar: boolean - To check if the password contains any special |
| 24 | + characters. Defaults to true and enables the check. |
| 25 | +- containsAlphabet: boolean - To check if the password contains any alphabets. |
| 26 | + Defaults to true and enables the check. |
| 27 | + |
| 28 | +## Usage |
| 29 | + |
| 30 | +```typescript |
| 31 | +import { checkPassword } from "https://deno.land/x/password-checker/mods.ts"; |
| 32 | + |
| 33 | +const passwordString: string = "randomPassword123!."; |
| 34 | + |
| 35 | +let isPasswordValid: boolean; |
| 36 | + |
| 37 | +// Default case which checks if password is alphanumeric and contains special characters |
| 38 | +isPasswordValid = checkPassword({ password: passWordString }); |
| 39 | + |
| 40 | +// To set minimum length of password |
| 41 | +isPasswordValid = checkPassword({ password: passwordString, minLen: 5 }); |
| 42 | + |
| 43 | +// To set maximum length of password |
| 44 | +isPasswordValid = checkPassword({ |
| 45 | + password: passwordString, |
| 46 | + minLen: 5, |
| 47 | + maxLen: 12, |
| 48 | +}); |
| 49 | + |
| 50 | +// To disable number check on password |
| 51 | +isPasswordValid = checkPassword({ |
| 52 | + password: passwordString, |
| 53 | + containsNum: false, |
| 54 | +}); |
| 55 | + |
| 56 | +// To disable alphanumeric check on password |
| 57 | +isPasswordValid = checkPassword({ |
| 58 | + password: passwordString, |
| 59 | + containsNum: false, |
| 60 | + containsAlphabet: false, |
| 61 | +}); |
| 62 | + |
| 63 | +// To disable special characters check on password |
| 64 | +isPasswordValid = checkPassword({ |
| 65 | + password: passwordString, |
| 66 | + containsSpecialChar: false, |
| 67 | +}); |
| 68 | +``` |
| 69 | + |
| 70 | +## License |
| 71 | + |
| 72 | +This package is published under the Unlicense. For more information, see the |
| 73 | +accompanying LICENSE file. |
| 74 | + |
| 75 | +<br> |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +<br> |
| 80 | + |
| 81 | +### PS: |
| 82 | + |
| 83 | +If you find this package useful, please consider giving a |
| 84 | +[star](https://github.com/arghyadeep-k/deno-password-checker) to this project on |
| 85 | +Github. |
| 86 | + |
| 87 | +And, if you are willing to [buy me a coffee](https://ko-fi.com/arghyadeep), that |
| 88 | +would be awesome. :) |
| 89 | + |
| 90 | +<a href='https://ko-fi.com/arghyadeep' target='_blank'><img height='36' style='border:0px;height:36px;' src='https://cdn.ko-fi.com/cdn/kofi1.png?v=2' border='0' alt='Buy Me a Coffee at ko-fi.com' /></a> |
0 commit comments