Robert Jaros
11/05/2023, 8:17 AMashmelev
11/08/2023, 5:48 PMform<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:
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 constructionRobert Jaros
11/08/2023, 5:49 PMRobert Jaros
11/08/2023, 5:52 PMnovalidate
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.ashmelev
11/08/2023, 6:18 PMnovalidate = true
under the covers would clarify things for people like me 🙂Robert Jaros
11/08/2023, 8:33 PMashmelev
11/08/2023, 8:43 PM