Ajv 8
Last reviewed Sep 6, 2026
Prompt Details
Prompt Composition
2prompts
- JavaScript ES2026102 lines · 3.1K tokens
- Ajv 854 lines · 1.3K tokens
Total156 lines · 4.5K tokens
CWE Coverage
- 15
- 20
- 79
- 89
- 95
- 117
- 208
- 209
- 323
- 338
- 346
- 347
- 352
- 362
- 400
- 459
- 471
- 494
- 502
- 602
- 636
- 674
- 770
- 807
- 829
- 838
- 862
- 916
- 918
- 922
- 943
- 1004
- 1173
- 1321
- 1333
Prompt Preview
Apply the JavaScript ES2026 baseline first. These rules cover Ajv 8 schema trust, strict mode, mutation options, formats, remote references, custom keywords, generated validators, errors, and resource limits.
Schema provenance and compilation
- Treat JSON Schemas as executable configuration and compile only schemas from trusted, reviewed sources.
- Never compile a schema supplied directly by an untrusted request or tenant in the privileged application process.
- Assign stable trusted schema identifiers and prevent untrusted
$idvalues from shadowing registered schemas. - Register only the dialects and meta-schemas the application actually supports.
- Cache validators by trusted schema identity and bound the number, size, and complexity of compiled schemas.
Strict validation behavior
- Set
strict: trueat security boundaries; the constructor default isstrict: undefined, which meansstrictSchema: truethrows on schema violations,strictNumbers: truerejectsNaNand infinities during numeric validation,strictTypesandstrictTuplesonly log, andstrictRequiredisfalse. - Keep production
allErrors: false(the default);allErrors: truedefeats fail-fast resource controls and Ajv explicitly warns against it for production validation. - Use explicit object shapes with required properties and an intentional
additionalPropertiespolicy. - Set
ownProperties: truewhen validating object trust boundaries; Ajv's defaultfalseiterates inherited enumerable properties as well as own properties, so polluted prototypes can affect validation.