Skip to content

Commit 40a1fc2

Browse files
seportsaintedlama
authored andcommittedOct 14, 2019
chore: more descriptive customValidator docs in readme (#285)
1 parent aa3d16f commit 40a1fc2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed
 

‎README.md

+20-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,26 @@ User.plugin(passportLocalMongoose, options);
133133
* encoding: specifies the encoding the generated salt and hash will be stored in. Defaults to 'hex'.
134134
* limitAttempts: specifies whether login attempts should be limited and login failures should be penalized. Default: false.
135135
* maxAttempts: specifies the maximum number of failed attempts allowed before preventing login. Default: Infinity.
136-
* passwordValidator: specifies your custom validation function for the password in the form 'function(password,cb)'. Default: validates non-empty passwords.
136+
* passwordValidator: specifies your custom validation function for the password in the form:
137+
```
138+
passwordValidator = function(password,cb) {
139+
if (someValidationErrorExists(password)) {
140+
return cb('this is my custom validation error message')
141+
}
142+
// return an empty cb() on success
143+
return cb()
144+
}
145+
```
146+
Default: validates non-empty passwords.
147+
* passwordValidatorAsync: specifies your custom validation function for the password with promises in the form:
148+
```
149+
passwordValidatorAsync = function(password) {
150+
return someAsyncValidation(password)
151+
.catch(function(err){
152+
return Promise.reject(err)
153+
})
154+
}
155+
```
137156
* usernameQueryFields: specifies alternative fields of the model for identifying a user (e.g. email).
138157
* findByUsername: Specifies a query function that is executed with query parameters to restrict the query with extra query parameters. For example query only users with field "active" set to `true`. Default: `function(model, queryParameters) { return model.findOne(queryParameters); }`. See the examples section for a use case.
139158

0 commit comments

Comments
 (0)
Please sign in to comment.