aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-03-16 19:01:43 +0100
committerRobert Jaros <rjaros@finn.pl>2020-03-16 19:01:43 +0100
commite2b18ce34be2ac5d281e7e2b191bacef8f55acff (patch)
treed4249f6eca0362d540c551135e862c57fc288864
parent460c41d4a823589d1f60c7bd31d0a350a1a783f2 (diff)
downloadkvision-e2b18ce34be2ac5d281e7e2b191bacef8f55acff.tar.gz
kvision-e2b18ce34be2ac5d281e7e2b191bacef8f55acff.tar.bz2
kvision-e2b18ce34be2ac5d281e7e2b191bacef8f55acff.zip
Fix forms validation for hidden fields.
-rw-r--r--src/main/kotlin/pl/treksoft/kvision/form/Form.kt2
1 files changed, 1 insertions, 1 deletions
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<K : Any>(
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"