createPrecompiledValidator() takes its localizer and suppressDuplicateFiltering in an options object
Detect
- Your code calls
createPrecompiledValidator()from@rjsf/validator-ajv8or@rjsf/validator-atawith alocalizerorsuppressDuplicateFilteringas its third or fourth argument, includingcreatePrecompiledValidator(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 4for a fourth argument, orTS2559: Type '(e: any) => void' has no properties in common with type 'PrecompiledValidatorOptionsType<StrictRJSFSchema>'for alocalizerpassed as the third. - In untyped code that still passes them positionally, nothing reports it: a
localizerthird stops localizing, and a fourth argument is ignored. Anullthird throws aTypeError.
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
- Localized error messages still appear, now with quoted property names as a localizer gets quoted property names describes.
- Duplicate filtering behaves as before.
Also read: