Skip to content

Commit

Permalink
fix: Fixes rjsf-team#3825 Precompiled validator resolve root schema
Browse files Browse the repository at this point in the history
  • Loading branch information
cwendtxealth committed Aug 13, 2023
1 parent dabdae4 commit eec9c11
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions packages/validator-ajv8/src/precompiledValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ export default class AJV8PrecompiledValidator<
*/
readonly rootSchema: S;

/** The root schema resolved top level refs
*
* @private
*/
readonly resolvedRootSchema: S;

/** The `ValidatorFunctions` map used to construct this validator
*
* @private
Expand Down Expand Up @@ -72,7 +66,6 @@ export default class AJV8PrecompiledValidator<
this.validateFns = validateFns;
this.localizer = localizer;
this.mainValidator = this.getValidator(rootSchema);
this.resolvedRootSchema = retrieveSchema(this, rootSchema, rootSchema);
}

/** Returns the precompiled validator associated with the given `schema` from the map of precompiled validator
Expand Down Expand Up @@ -109,7 +102,8 @@ export default class AJV8PrecompiledValidator<
* @throws - Error when the schema provided does not match the base schema of the precompiled validator
*/
rawValidation<Result = any>(schema: S, formData?: T): RawValidationErrorsType<Result> {
if (!isEqual(schema, this.resolvedRootSchema)) {
const resolvedRootSchema = retrieveSchema(this, this.rootSchema, this.rootSchema, formData);
if (!isEqual(schema, resolvedRootSchema)) {
throw new Error(
'The schema associated with the precompiled schema differs from the schema provided for validation'
);
Expand Down

0 comments on commit eec9c11

Please sign in to comment.