ajv-validator / ajv-validator/ajv
`minProperties` and `removeAdditional` does not collaborate well
- Vorherrschende Sprache
- TypeScript
- Sterne
- 14.8k
- Forks
- 1k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
**What version of Ajv are you using? Does the issue happen if you use the latest version?**
latest (8.17.1)
**Ajv options object**
```javascript
{ removeAdditional: "all" }
```
**JSON Schema**
```json
{
"type": "object",
"minProperties": 1,
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "string"
}
}
}
```
**Sample data**
```javascript
const shouldError1 = {};
const shouldError2 = { foobar: "baz" };
const shouldPass = { foo: "bar" };
```
**Your code**
**Validation result, data AFTER validation, error messages**
```javascript
const validate = new Ajv(options).compile(schema);
const shouldError1 = {};
console.log(validate(shouldError1), shouldError1); // valid = false, data = {}
const shouldError2 = { foobar: "baz" };
console.log(validate(shouldError2), shouldError2); // valid = true, data = {}
const shouldPass = { foo: "bar" };
console.log(validate(shouldPass), shouldPass); // valid = true, data = { foo: "bar" }
```
**What results did you expect?**
The object with only additional properties is expected to have error for not satisfy the `minProperties` constraint after additional properties has been removed.
**Are you going to resolve the issue?**
Currently not yet.
Beitragsleitfaden
Bewertung
Dieses Issue wurde noch nicht bewertet.