ajv-validator / ajv-validator/ajv

[Proposal] Support empty enum keyword with validateSchema: false option

Đang mở
#1,893 5 bình luận 0 reaction 0 người được giao Xem trên GitHub
usage
Ngôn ngữ chính
TypeScript
Star
14.8k
Fork
1k
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

**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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.