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

Precompiled validator code must be regenerated

Detect​

  • In your build: a script calling compileSchemaValidators( or compileSchemaValidatorsCode(, and the validator module it writes, checked in or generated.
  • In your code: createPrecompiledValidator( loading that module, or schemaParser imported from @rjsf/utils.
  • Thrown error at runtime: No precompiled validator function was found from code generated by 6.x.

Change​

The form hands the validator a $ref to where a condition or option sits in the root, in place of a copy of it (see A ValidatorType of your own is handed $refs into the root schema and has to resolve them), so the schemas a precompiled validator compiles are named by the schema graph. Regenerate precompiled validator code with compileSchemaValidators() or compileSchemaValidatorsCode(): code generated by an earlier version throws No precompiled validator function was found. Both are imported from the compileSchemaValidators subpath; see compileSchemaValidators is imported from its own subpath.

The new getValidationSchemas(rootSchema) lists what is compiled: the root, a $ref to each if, each then and else beside an if and each option, to the property each option declares under any discriminator.propertyName in the root, the copy of an option scoring derives where it drops a required, each dependency condition, and, where an option is a boolean, {}, the schema SchemaField retrieves it as, with { not: {} }, the schema a false option reads as. The list depends on the root alone and grows with its size.

schemaParser(), its 6.x name, is gone; call getValidationSchemas() in its place. The other utilities @rjsf/utils stopped exporting are listed in @rjsf/utils no longer exports utilities no other RJSF package uses.

-import { schemaParser } from '@rjsf/utils';
-const schemaMap = schemaParser(rootSchema);
+import { getValidationSchemas } from '@rjsf/utils';
+const schemaMap = getValidationSchemas(rootSchema);

A schema a merge makes has no place in the root and is not compiled. An option made by merging two lists, such as the oneOfs of two patternProperties matching the same key, is scored against each option it was built from, each compiled; an option a customMergeAllOf rewrites throws No precompiled validator function was found when the form scores it, as in 6.11.0, and so does an option of a list both options of a merged pair declare below it, as for one of its properties. The error names the subschema when the schema it has no function for is a $ref.

A subschema the root holds in several places, as a schema module that reuses one object holds it, is compiled at each place, so code compiled from the module serves an equal copy of it, such as its JSON, and the other way round, as in 6.11.0.

Verify​

The regenerated module loads and the form validates without No precompiled validator function was found. Schemas that failed to compile or failed in the form now work:

Schema6.11.07.0.0
definitions.node recursing through u: { anyOf: [{ $ref: node }, { type: 'string' }] }, used as v: { oneOf: [{ $ref: node }, { type: 'number' }] }the compile throws can't resolve reference #/definitions/nodecompiles; v matches { n: 'a', u: { n: 'b' } } to option 0 and 5 to option 1
a root with dependencies: { a: ['b'] } and oneOf: [{ $ref: '#' }, { properties: { c } }] (#5452 c)the compile overflows the stackcompiles
an option with properties: { id } and patternProperties: { '^s_': ..., '^s_n': ... }, data { id: 'a', s_na: 'xx' } (#5454)scoring the retrieved options throws No precompiled validator function was foundoption 0
an option { $id: 'myOption', properties: { id }, additionalProperties: { type: 'string' } }, data { id: 'a', extra: 'x' } (#5455)the compile throws schema with key or id "myOption" already existsoption 0
s: { allOf: [{ discriminator: { propertyName: 'kind' } }], oneOf: [A, B] }, or s: { discriminator, allOf: [{ oneOf: [A, B] }] }, where A and B declare kind as const 'a' and 'b', data { b: 'q' }scoring the options throws No precompiled validator function was foundoption 1

If you can't preserve it​

An option your customMergeAllOf rewrites can't be precompiled, as in 6.11.0. Validate such a form with the validator that compiles at runtime.

Also read: