<https://kotlinlang.slack.com/archives/C8C4JTXR7/p...
# kvision
a
Robert, two comments: 1.) in the form instantiation,
Copy code
form<UserForm>(novalidate = true, className = "row g-3 needs-validation")
the
novalidate = true
to reads as "do not validate this form", but then you proceed to have form validation code.... I assume that the validation code is there because one day you may want to activate the form validation with
novalidate = false
, but if that's a bad assumption, then I am confused about that flag. 2.) The validation code for Username feels backwards to me. Specifically this code:
Copy code
val invalidClass = if (validation[UserForm::username]?.isInvalid == true) "is-invalid" else null
                        text(required = true, id = it, className = "form-control" % invalidClass) {
                            ariaDescribedby = "inputGroupPrepend"
                        }.bind(UserForm::username, {
                            "Username must be at least 10 characters long."
                        }) { text ->
                            text.value == null || text.value!!.length >= 10
                        }
                        div("invalid-feedback") {
                            +(validation[UserForm::username]?.invalidMessage ?: "Please choose a username.")
                        }
It's not unreadable, but having the error message precede the test just feels odd In the end, it's readable and understandable, but a little odd in the construction
r
Thanks for your feedback!
The
novalidate
flag add corresponding html attribute, which disables built-in browser validation, so we can have custom validation and custom styling. I suppose it could be added automatically when validation is used to avoid confusion.
a
Ahhhh... I'm primarily a back-end (Spring) developer - which is why I like KVision. That why I do not readily identify "browser-specific" attributes for what they are. Thanks for the clarification. I agree that forcing
novalidate = true
under the covers would clarify things for people like me 🙂
r
I've made some changes to the validation API. It's better now. Thanks once again for your time.
a
You are welcome, of course - but the thanks should go to you. Thank you for such a great piece of work. KVision is really a wonderful tool
âž• 1