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

createPrecompiledValidator() takes its localizer and suppressDuplicateFiltering in an options object

Detect​

  • Your code calls createPrecompiledValidator() from @rjsf/validator-ajv8 or @rjsf/validator-ata with a localizer or suppressDuplicateFiltering as its third or fourth argument, including createPrecompiledValidator(validateFns, schema, undefined, 'all').
  • Your code passes a data type argument, such as createPrecompiledValidator<MyData>().
  • The type checker reports TS2554: Expected 2-3 arguments, but got 4 for a fourth argument, or TS2559: Type '(e: any) => void' has no properties in common with type 'PrecompiledValidatorOptionsType<StrictRJSFSchema>' for a localizer passed as the third.
  • In untyped code that still passes them positionally, nothing reports it: a localizer third stops localizing, and a fourth argument is ignored. A null third throws a TypeError.

Change​

The third argument is now an options object holding localizer, suppressDuplicateFiltering and customMergeAllOf, and there is no fourth. Drop a leftover data type argument too, since the first type argument is now the schema type, as ValidatorType and customizeValidator take the schema type first describes:

-const validator = createPrecompiledValidator<MyData>(validateFns, schema, localize, suppressDuplicateFiltering);
+const validator = createPrecompiledValidator(validateFns, schema, { localizer: localize, suppressDuplicateFiltering });

For customMergeAllOf, see schema functions take a SchemaContext. For every option, see createPrecompiledValidator() in the @rjsf/validator-ajv8 and @rjsf/validator-ata references.

Verify​

Also read: