Validate only one path
#12004
-
I have the following long schema: const mySchema = new mongoose.Schema({
// some stuff, firstName, lastName ... etc
password: {
type: String,
minLength: 8,
maxLength: 120,
}
}) And I am inside one of the routes, I want to run validation on the password filed only. Is there something that I can do in Mongoose such as:
Is there something like that? |
Beta Was this translation helpful? Give feedback.
Answered by
vkarpov15
Jul 1, 2022
Replies: 1 comment 5 replies
-
|
Beta Was this translation helpful? Give feedback.
5 replies
Answer selected by
samislam
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mySchema.path('password').doValidate(value, fn)
. Or you can dodoc.validate(['password'])
.