From e2b18ce34be2ac5d281e7e2b191bacef8f55acff Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Mon, 16 Mar 2020 19:01:43 +0100 Subject: Fix forms validation for hidden fields. --- src/main/kotlin/pl/treksoft/kvision/form/Form.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt index 3eb94f64..783653ce 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt @@ -311,7 +311,7 @@ class Form( if (markFields) control.validatorError = trans(fieldsParams?.requiredMessage) ?: "Value is required" true } else { - val validatorPassed = control.visible && (fieldsParams?.validator?.invoke(control) ?: true) + val validatorPassed = !control.visible || (fieldsParams?.validator?.invoke(control) ?: true) if (markFields) { control.validatorError = if (!validatorPassed) { trans(fieldsParams?.validatorMessage?.invoke(control)) ?: "Invalid value" -- cgit