Skip to content

Commit

Permalink
use precompiledValidator @rjsf/utils.deepEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbrasileiro committed Jan 9, 2025
1 parent 9a606ae commit 0fb1cc0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ should change the heading of the (upcoming) version to include a major version b
- Fixed issue with formData not updating when dependencies change, fixing [#4325](https://github.com/rjsf-team/react-jsonschema-form/issues/4325)
- Fixed issue with assigning default values to formData with deeply nested required properties, fixing [#4399](https://github.com/rjsf-team/react-jsonschema-form/issues/4399)

## @rjsf/validator-ajv8

- Switched uses of `lodash.isEqual()` to `@rjsf/utils.deepEquals` at precompiledValidator.

# 5.23.2

## @rjsf/core
Expand Down
7 changes: 4 additions & 3 deletions packages/validator-ajv8/src/precompiledValidator.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ErrorObject } from 'ajv';
import get from 'lodash/get';
import { deepEqual } from 'fast-equals';

import {
CustomValidator,
deepEquals,
ErrorSchema,
ErrorTransformer,
FormContextType,
Expand Down Expand Up @@ -92,10 +93,10 @@ export default class AJV8PrecompiledValidator<
* @param [formData] - The form data to validate if any
*/
ensureSameRootSchema(schema: S, formData?: T) {
if (!deepEqual(schema, this.rootSchema)) {
if (!deepEquals(schema, this.rootSchema)) {
// Resolve the root schema with the passed in form data since that may affect the resolution
const resolvedRootSchema = retrieveSchema(this, this.rootSchema, this.rootSchema, formData);
if (!deepEqual(schema, resolvedRootSchema)) {
if (!deepEquals(schema, resolvedRootSchema)) {
throw new Error(
'The schema associated with the precompiled validator differs from the rootSchema provided for validation'
);
Expand Down

0 comments on commit 0fb1cc0

Please sign in to comment.