bradwestfall / bradwestfall/house-rules
Passing values to `validate` should output warnings when not part of the schema
- Dominant language
- JavaScript
- Stars
- 10
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
Consider
```js
const schema = new Schema({
id: Is.numeric().positive().integer().required(),
name: Is.string().ascii().required()
})
```
and then validating
```js
schema.validate({
id: 123,
name: 'John',
email: 'not.an.email'
})
```
This validation returns no errors. Which it should not since email is not defined in the schema and by that virtue, email is an optional, free-text value, but I think there are real-time situations where rules could be forgotten to be passed into the schema with potentially serious consequences. This also applies for `schema.clone`.
Shouldn't `validate` in this case output a warning about email not being part of the schema?
Perhaps `new Schema`, `schema.clone` and/or `validate` method could take an optional second argument as a configuration object where the option for this would be something like `suppressWarnings: false`?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the Schema constructor, validate, and clone entry points mentioned in the issue. Decide how undeclared input fields should produce warnings and how an optional configuration object should control suppression across these methods. Done means the warning behavior and clone semantics are defined clearly enough to implement and verify.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100