Skip to main content
Version: Current (v7.0.0-beta.3)

createPrecompiledValidator() takes the form's customMergeAllOf

Detect​

  • In your code, createPrecompiledValidator() from @rjsf/validator-ajv8 or @rjsf/validator-ata used with a Form that sets customMergeAllOf.
  • At runtime, the error "The schema associated with the precompiled validator differs from the rootSchema provided for validation", for a root schema with an allOf.

Change​

A precompiled validator is tied to one root schema compiled once, so it takes the form's customMergeAllOf at construction instead of per call:

-const validator = createPrecompiledValidator(validateFns, schema);
+const validator = createPrecompiledValidator(validateFns, schema, { customMergeAllOf });

It uses it when it resolves its own root schema to check the schema it is handed, so the error no longer comes from validateFormData(), nor from a schema function scoring oneOf/anyOf options or resolving a condition against that root schema. The third argument is an options object; see createPrecompiledValidator() takes its localizer in an options object.

compileSchemaValidators() and compileSchemaValidatorsCode() take no customMergeAllOf: they compile the subschemas the root names, and a schema a merge makes is not compiled; see Precompiled validator code must be regenerated.

Verify​

Under liveValidate, a form with customMergeAllOf and an allOf in its root schema validates without the "differs from the rootSchema" error.

Also read: