Skip to content

Custom Validation started to fail with upgrade to version 5.24.2 #4475

@rgciocan

Description

@rgciocan

Prerequisites

What theme are you using?

validator-ajv8

Version

5.24.2

Current Behavior

Using custom validation examples from the documentation, when rendering the schema I get the browser console error:

Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
at areObjectsEqual (http://localhost:3000/bundle.js:550581:25)
at comparator (http://localhost:3000/bundle.js:550840:17)
at Object.equals (http://localhost:3000/bundle.js:550928:16)
at areArraysEqual (http://localhost:3000/bundle.js:550500:20)
at comparator (http://localhost:3000/bundle.js:550793:20)
at Object.equals (http://localhost:3000/bundle.js:550928:16)
at isPropertyEqual (http://localhost:3000/bundle.js:550718:15)
at areObjectsEqual (http://localhost:3000/bundle.js:550592:14)
at comparator (http://localhost:3000/bundle.js:550840:17)
at Object.equals (http://localhost:3000/bundle.js:550928:16)

Also, testing the code with jest I get:
detail: RangeError: Maximum call stack size exceeded
at comparator (/home/rgciocan/WORK/dev/sources/marketplace-web/node_modules/fast-equals/src/comparator.ts:76:29)
at Object.equals (/home/rgciocan/WORK/dev/sources/marketplace-web/node_modules/fast-equals/src/comparator.ts:307:12)
at isPropertyEqual (/home/rgciocan/WORK/dev/sources/marketplace-web/node_modules/fast-equals/src/equals.ts:349:11)
at areObjectsEqual (/home/rgciocan/WORK/dev/sources/marketplace-web/node_modules/fast-equals/src/equals.ts:158:10)
at comparator (/home/rgciocan/WORK/dev/sources/marketplace-web/node_modules/fast-equals/src/comparator.ts:194:9)

This is one of the examples I've used:

const validator = customizeValidator<Record<string, any>>({
		ajvOptionsOverrides: {
			strictNumbers: true
		}
	});

return 
	<Form<Record<string, any>>
		className={`rjsf tw-bg-unbranded tw-text-unbranded ${className}`}
		schema={schema}
		formData={data}
		extraErrors={fieldErrors}
		showErrorList={false}
		uiSchema={uiSchema}
		widgets={widgets}
		validator={validator}
		templates={templates}
		onChange={(formData: any) => onChange?.(formData)}
		transformErrors={(errs: any) => {
			setTimeout(() => onErrors?.(errs), 0);
			return errs;
		}}
		liveValidate={!!onErrors && !schema?.readOnly}
		liveOmit
		omitExtraData
	/>

When I use a standard validator, rendering of the schema works fine.

Expected Behavior

Schema should render fine.

Steps To Reproduce

No response

Environment

- OS:
- Node:
- npm:

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions