regexbuddy
Advanced tools
Comparing version 0.9.5 to 0.9.6
{ | ||
"name": "regexbuddy", | ||
"version": "0.9.5", | ||
"version": "0.9.6", | ||
"description": "Implement regex expressions in JavaScript", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -35,4 +35,2 @@ # RegexBuddy | ||
**NOTE:** The password validation method simply returns `true` or `false`. | ||
For password validation, you can simply use: | ||
@@ -57,3 +55,3 @@ | ||
```javascript | ||
regexBuddy.password(input).validate({ minlength: 8, requireSpecialCharacter: false }); | ||
regexBuddy.password(input).validate({ minLength: 8, requireSpecialCharacter: false }); | ||
``` | ||
@@ -63,14 +61,25 @@ | ||
**NOTE:** The password validation method returns an object structured like this: | ||
```javascript | ||
{ | ||
valid: boolean, | ||
errors: [ validationErrors ] || null | ||
} | ||
``` | ||
This gives you the option of serving the client an array of the criteria not met when creating a password, or simply using the password validation method in a conditional expression. And the `valid` property was added for those who prefer using explicit conditional evaluation over implicit "truthy" methods for something like a password. | ||
An example of how to use this in your code would be: | ||
```javascript | ||
const validPassword = regexBuddy.password(input).validate({ minlength: 8, requireSpecialCharacter: false }); | ||
const passwordCheck = regexBuddy.password(input).validate({ minlength: 8, requireSpecialCharacter: false }); | ||
``` | ||
This would let you reference the `validPassword` variable in a simple way, like this conditional statement: | ||
This would let you reference the `passwordCheck` variable in a simple way, like these examples: | ||
```javascript | ||
// If a password is valid | ||
if (validPassword) { | ||
// Run this code | ||
// If a password is invalid | ||
if (passwordCheck.errors) { | ||
// You can then map the array of errors in passwordCheck.errors to a DOM object, like a toast, modal, etc. | ||
... | ||
@@ -80,6 +89,6 @@ } | ||
Or implement in your corresponding template file, like this: | ||
Or implement as a simple, explicit conditional in your corresponding template file, like this example, where a submit button is disabled when there are any errors with the user's input value: | ||
```html | ||
<button type="submit" disabled={!validPassword}>Submit</button> | ||
<button type="submit" disabled={!passwordCheck.valid}>Submit</button> | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10018
90