konform
konform copied to clipboard
Also keep the `value` in the `Invalid` result
Looking at the implementations of ValidationResult I find these:
public data class Invalid(
override val errors: List<ValidationError>,
) : ValidationResult<Nothing>() { ... }
public data class Valid<T>(
val value: T,
) : ValidationResult<T>() { ... }
Why is does only the Valid result carry the values?
When I pass the ValidationResult to my HTML render function I now always have to pass the formContent parameter as well. Because in the Invalid case I also want to render the form, but with the invalid values inside!
So my render functions look like:
fun renderForm(validationResult: ValidationResult, formContent: SomeFormDto) { ... }
Instead of just...
fun renderForm(validationResult: ValidationResult) { ... }
...if the value was also part of the Invalid implementation of ValidationResult.
This issue may be similar to https://github.com/konform-kt/konform/issues/194