A form's customMergeAllOf and defaultFormStateBehavior apply where they used to be dropped
Detect
- In your code, a
Formthat setscustomMergeAllOfordefaultFormStateBehavior, especially withomitExtraData, acustomValidate, orallOfin its schema. - A direct call to a validator's
validateFormData()with acustomValidate.
Change
The schema functions used to copy these settings one by one into every function they called, and several calls left one out (#4383, #4385). Four places that dropped a setting now apply it:
SchemaUtilsType.omitExtraData()never passed the form'scustomMergeAllOfon, so theallOfs it merged were always merged the default way.- An
allOfreached through a$refoption of aoneOfinsidedependencieswas always merged the default way. - The defaults handed to
customValidatewere computed with neither thecustomMergeAllOfnor thedefaultFormStateBehaviorof the form. - The precompiled validators of
@rjsf/validator-ajv8and@rjsf/validator-ataresolved their root schema with the defaultallOfmerge, so underliveValidatea form with acustomMergeAllOfand anallOfin its root schema failed with "The schema associated with the precompiled validator differs from the rootSchema provided for validation". They now resolve it with thecustomMergeAllOfthey were constructed with; see createPrecompiledValidator() takes the form's customMergeAllOf.
validateFormData() takes one new optional trailing parameter, getCustomValidateFormData: a function returning the form data to hand customValidate, with the defaults already applied. Form supplies it from its own SchemaUtils. Left out, the validator computes the defaults itself exactly as it did in v6, so a direct caller keeps v6 behaviour. To get the form's settings, pass it:
validator.validateFormData(formData, schema, customValidate, transformErrors, uiSchema);
+validator.validateFormData(formData, schema, customValidate, transformErrors, uiSchema, () => schemaUtils.getDefaultFormState(schema, formData, true, undefined, uiSchema));
Verify
- Extra data omitted from a form with
customMergeAllOfmatches the merged schema you expect. customValidatereceives defaults that follow yourdefaultFormStateBehavior.
Also read: