diff --git a/packages/xforms-engine/src/instance/internal-api/ValidationContext.ts b/packages/xforms-engine/src/instance/internal-api/ValidationContext.ts index 89f461dc..ffaa8606 100644 --- a/packages/xforms-engine/src/instance/internal-api/ValidationContext.ts +++ b/packages/xforms-engine/src/instance/internal-api/ValidationContext.ts @@ -17,6 +17,7 @@ interface ValidationContextDefinition { export interface ValidationContext extends EvaluationContext, SubscribableDependency { readonly definition: ValidationContextDefinition; + isRelevant(): boolean; isRequired(): boolean; isBlank(): boolean; } diff --git a/packages/xforms-engine/src/lib/reactivity/validation/createValidation.ts b/packages/xforms-engine/src/lib/reactivity/validation/createValidation.ts index ada00a9c..7be87a06 100644 --- a/packages/xforms-engine/src/lib/reactivity/validation/createValidation.ts +++ b/packages/xforms-engine/src/lib/reactivity/validation/createValidation.ts @@ -81,7 +81,7 @@ const createConstraintValidation = ( const message = createViolationMessage(context, 'constraintMsg', constraintMsg); return createMemo(() => { - if (context.isBlank() || isValid()) { + if (!context.isRelevant() || context.isBlank() || isValid()) { return constraintValid(); } @@ -123,7 +123,7 @@ const createRequiredValidation = ( const message = createViolationMessage(context, 'requiredMsg', requiredMsg); return createMemo(() => { - if (isValid()) { + if (!context.isRelevant() || isValid()) { return requiredValid(); }