[V2] defaultValues of formOptions.looseSchema() should infer optional properties #2347
Unanswered
lucas-dtrn
asked this question in
Ideas
Replies: 1 comment
|
Sounds reasonable to me. Shouldn't have to be too tough to adjust, so expect this by the next alpha. I'll let you know in this discussion when it's out. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When using appFormOptions.looseSchema, the inferred type of defaultValues currently requires every property defined by the validation schema to be present.
For example:
The inferred defaultValues type is effectively:
Although each value may be undefined, both properties are still required. This forces users to explicitly assign undefined to every field.
For a loose schema, the properties themselves should instead be optional:
This would allow partial or empty default values:
Expected behavior
looseSchema should infer optional properties for defaultValues, allowing fields to be omitted entirely.
Actual behavior
The properties are required, even though their values may be undefined, so all fields must be explicitly declared.
All reactions