ajv-validator / ajv-validator/ajv
[Proposal] Support empty enum keyword with validateSchema: false option
- Lingua principale
- TypeScript
- Stelle
- 14.8k
- Fork
- 1k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
6.12.3 - no errors thrown
8.9.0 - throws an error
**Ajv options object**
```javascript
{validateSchema: false}
```
**JSON Schema**
```json
{enum: []}
```
**Sample data**
```json
```
**Your code**
```javascript
const ajv = new Ajv({validateSchema: false});
ajv.compile({enum:[]}) // throws
```
**Validation result, data AFTER validation, error messages**
```
Error is thrown: "enum must have a non-empty array"
```
**What results did you expect?**
No errors thrown during compilation if `validateSchema` is set to `false`
**Are you going to resolve the issue?**
I would give it a go with guidance on how the error should be handled.
Workaround for consumers of course is just to catch the error, but it's not something I would have expected and I couldn't see it listed as one of the intentional breaking changes.
Guida per i contributori
Apri la guida per i contributori
Valutazione
Questa issue non è ancora stata valutata.