A required field should be ignored in case of update
thxmxx opened this issue · 2 comments
thxmxx commented
Most of the time the Required statement is only applicable for creating the documents. After creation I cannot force the user to fill these fields again. Is there any option to bypass this?
I am copying the schema tree
const schemaTree = schema.tree
delete schemaTree._id;
delete schemaTree.updatedAt;
delete schemaTree.createdAt;
delete schemaTree.__v;
router.put('/:id',
body( schemaTree ),
update)
diegohaz commented
You can override the option when passing the object to body
:
body({ ...schemaTree, field: { ...scemaTree.field, required: false } })
Mustafax06 commented
Do I have to do this to all fields? Can I just override them all at once?