ajv-validator / ajv-validator/ajv
Option to treat `null` as lack of value
- Lingua principale
- TypeScript
- Stelle
- 14.8k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Seems closely related to https://github.com/ajv-validator/ajv/issues/937
**What version of Ajv you are you using?**
v6.12.5
**What problem do you want to solve?**
In JavaScript, when processing configuration objects it's typical to treat _lack of value_, `null` and `undefined` as equal.
e.g. when one wants to override `{ foo: "bar" }`, with `{ foo: null }`, it's clear that intention is to clear `foo` from object.
Currently schema validation will not accept `null` values for properties unless it's explicitly allowed in schema. Still allowing it for every configured property seems as very verbose and maintenance wise problematic practice.
_In my opinion if property is optional, `null` naturally should be supported as a valid value, per schema_
**What do you think is the correct solution to problem?**
Ideally, an option as `normalizeNoValues` that would treat _lack of value_, `null` and `undefined` as equal.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.