diff --git a/packages/validator-ajv8/src/precompiledValidator.ts b/packages/validator-ajv8/src/precompiledValidator.ts index da70ad85a0..dd1608f994 100644 --- a/packages/validator-ajv8/src/precompiledValidator.ts +++ b/packages/validator-ajv8/src/precompiledValidator.ts @@ -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 @@ -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 @@ -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(schema: S, formData?: T): RawValidationErrorsType { - 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' );