ajv-validator / ajv-validator/ajv

Empty key is not validated by "required" keyword

Open
#2,077 3 comments 0 reactions 0 assignees View on GitHub
bug report limitation
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.