konform icon indicating copy to clipboard operation
konform copied to clipboard

Programatically list all errors

Open AWinterman opened this issue 4 years ago • 2 comments

Currently, there is no way to programatically list all the errors associated with an object.

Yes, you can call ValidationResult.errors but the dataPath is computed in a non-public method, and there's no way to map it back to the property that errored without duplicated the computation.

Essentially I would like to do the following:

  1. define a check for each property
  2. map that check to a wire representation
  3. have control over the wire representation.

The Validation.dataPath method is a serialized representaiton of the error. I need a kotlin one.

I can almost get there simply by passing around references to the object properties (which has its own problems), but the handling for arrays puts it over the edge of inconvenience.

AWinterman avatar Jun 24 '20 19:06 AWinterman

What do you mean by "map that check to a wire representation".

Could you provide a minimal example of the DSL/API you'd like to see?

nlochschmidt avatar Jun 29 '20 20:06 nlochschmidt

if the errors object simply had a reference to the properties that are erroring, that would be sufficient. Maybe a linked list of the properties that make up the path?

AWinterman avatar Jun 30 '20 16:06 AWinterman