konform icon indicating copy to clipboard operation
konform copied to clipboard

Also keep the `value` in the `Invalid` result

Open cies opened this issue 7 months ago • 1 comments

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.

cies avatar Jun 02 '25 22:06 cies

This issue may be similar to https://github.com/konform-kt/konform/issues/194

cies avatar Jun 02 '25 22:06 cies