ajv-validator / ajv-validator/ajv
Support for 'readyOnly'
- Lingua principale
- TypeScript
- Stelle
- 14.8k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**What version of Ajv you are you using?**
8.4.0
**What problem do you want to solve?**
json-schema has a `readOnly` property. This is _super handy_ because a really common use-case is for json-schema to describe an entity (lets say 'an article') and that schema to be re-used for both `GET` and `PUT` requests.
But if that schema has an `id` field, you kinda want to omit that on `PUT`. A different option to handle this is to have 2 schemas, or make `id` non-required, but the former is a pain to maintain, and the latter makes it somewhat inaccurate.
The `readOnly` annotation captures this use-case really well, so if there's a way we can tell Ajv: validate, but use the 'readOnly' case, it should remove those properties before validating.
**What do you think is the correct solution to problem?**
Not familiar enough with Ajv internals
**Will you be able to implement it?**
Unlikely =(
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.