You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with a schema containing transforms, it happens that the raw values types in the form don't match the schema.parse return type. This is the case in the checkboxes example documented in the readme where the type of the "input" is undefined|string and the resulting value is of type boolean. This also happen when working with text inputs storing arrays of values for example:
The type of zo.fields.myarray is generated from the parse output type (string[] in that case). Which leads to the compiler not allowing to call zo.fields.myarray without an index argument:
<inputtype="text"name={zo.fields.myarray()/*Error: An argument for 'index' was not provided*/}value="value1,value2"/>
Solution
Changing this line so that the FieldChain is computed from the parse input instead of the parse result would fix this.
Context
When working with a schema containing transforms, it happens that the raw values types in the form don't match the
schema.parse
return type. This is the case in the checkboxes example documented in the readme where the type of the "input" isundefined|string
and the resulting value is of typeboolean
. This also happen when working with text inputs storing arrays of values for example:Problem
With the following schema:
The type of
zo.fields.myarray
is generated from the parse output type (string[]
in that case). Which leads to the compiler not allowing to callzo.fields.myarray
without anindex
argument:Solution
Changing this line so that the FieldChain is computed from the parse input instead of the parse result would fix this.
The change should probably also be applied to the
ErrorChainFromSchema
type.I can make a PR if you want. :)
The text was updated successfully, but these errors were encountered: