bluelibs icon indicating copy to clipboard operation
bluelibs copied to clipboard

(x) Form Annotations, Validation and Errors

Open theodorDiaconu opened this issue 4 years ago • 0 comments

We should have:

  1. An easy way to specify and customise errors
  2. A documented way of doing it (docs)

Should we use validator-bundle and have a unified validation strategy across the board? Allowing us to have classes as models that represent the form.

And if that's the case couldn't we also decorate that class with form elements:

@Form
class Blabla extens XForm {
   @Form.Field({ render, defaultValue })
   @Is(a.string())
   firstName: string = "Something"; // Supports Default Values
   
    @Form.Field({ ... })
    @Is(a.number) 
    price() {
      // if element decorates a function this function is the actual render
       return <Ant.Form.Item><Input /></Ant.Form.Item>
    }
}

theodorDiaconu avatar Sep 14 '21 10:09 theodorDiaconu