Replies: 1 comment 6 replies
-
Custom validators: const mySchema = new mongoose.Schema({
x: { type: String, validate: v == null || v.length > 0 },
y: { type: String, validate: v == null || v.length > 0 }
}) |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have the following schema:
when a user from the front-end requests in his body:
this results in creating a field in MongoDB, but with an empty string.
I need a way to prevent this behavior by setting the empty strings to be undefined somehow.
Is there such an option in Mongoose? or do I have to predict my own middlewares for that?
Beta Was this translation helpful? Give feedback.
All reactions