Automattic / Automattic/mongoose
Using strict mode without 'throw' doesn't return errors for unknown properties
- Dominant language
- JavaScript
- Stars
- 27.5k
- Forks
- 4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 32
Description
Creating an object with a key that isn't contained by the schema, then validating it with strict mode set to throw, raises an exception with the message it used a key path that isn't known, which is good.
When strict mode is set to true however, it doesn't raise an error at all for unknown properties. Is there a way to use the functionality from throw, but do it silent. I'd like to have the error added to the array of errors instead of raising an exception.
Is this possible?
Contributor guide
Research direction
Start by reproducing validation of an object with an unknown schema key under strict mode set to true and compare it with strict mode set to throw. Trace the validation entry point and determine whether the unknown-property error is added to the errors array without raising; done means strict true reports the error while remaining non-throwing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, mongodb, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100