ajv-validator / ajv-validator/ajv

AllRequired triggers "strict mode: required property "<prop>" is not defined" in strict mode

Open
#1,540 1 comment 0 reactions 0 assignees View on GitHub
enhancement limitation
Dominant language
TypeScript
Stars
14.8k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

AJV v8.0.5
Ajv-keywords v5.0.0

**Options**
```
const ajv = new Ajv({
strict: true, // <<<<<
strictTuples: false,
allErrors: true,
verbose: true,
coerceTypes: true,
$data: true,
useDefaults: true,
allowUnionTypes: true,
});

// ... other plugins
ajvKeywords(ajv);
```

**Schema**
```
{
type: 'object',
additionalProperties: false,
allRequired: true,
properties: {
units: {
type: 'object',
allRequired: true,
additionalProperties: false,
properties: {
holeSizeFrom: {
type: 'string',
},
// ... other required props
}
},
},
};
```

**Error on compilation**
```
Error: strict mode: required property "holeSizeFrom" is not defined at "..longPath/properties/units/allRequired" (strictRequired)
```

When `allRequired: true` replaced with `required: ['holeSizeFrom', //... more props]` everything compiles fine.

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.