ajv-validator / ajv-validator/ajv
Empty key is not validated by "required" keyword
- Dominant language
- TypeScript
- Stars
- 14.8k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
8.11.0
**Ajv options object**
Without options
```javascript
```
**JSON Schema**
```json
{
"$schema":"http://json-schema.org/draft-07/schema",
"type":"object",
"properties":{
"": { "type": "number" }
},
"required": [ "" ]
}
```
**Sample data**
```json
{}
```
**Your code**
```javascript
const ajv = new Ajv();
const validate = ajv.compile(schema);
console.log("Broken example",validate(data))
```
https://runkit.com/hosekp/630f1b9d59cb9b000b008aaf
**Validation result, data AFTER validation, error messages**
No errors
**What results did you expect?**
I expect an error about missing "" property
**Are you going to resolve the issue?**
I have found a workaround. If you use loopRequired=0 option, it is working.
Contributor guide
Assessment
This issue has not been assessed yet.