Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
My use case involves validateStandardSchema. We have Zod schemas defined for our forms, and we are validating the forms with them using validateStandardSchema. We also have some of Angular's required() validators thrown in as well. The trouble is, we have a reused sub-schema that we need to add async validation to. This async Zod validation at some of the form leaf nodes (via async .superRefine() calls) causes the entire schema to return a promise instead of a synchronous value, and as such, Angular ignores the promise value whenever the form has other sync errors from the required() validators. To make matters worse, the Zod async validation is still run, but Angular is dropping the results on the floor.
So, my proposal is this: would it be possible/acceptable to add a configuration option to either the form itself, or to validateStandardSchema, to not ignore these async errors? I understand the reasoning to avoid expensive async validators when possible, but in this scenario, they aren't even being avoided, just ignored.
Proposed solution
Add a configuration option to FormOptions, called something like "processAsyncValidators", with possible values of "whenSyncValid" (default), and "always", which is consumed in validateAsync().
Alternatives considered
- Create separate sync and async schemas: rejected because the composable schema structure would have to be duplicated unnecessarily
- Create more granular, field-level schemas: rejected because this violates the concept of having a single standard schema for a form, and shifts complexity from the schema to the Angular component
Which @angular/* package(s) are relevant/related to the feature request?
forms
Description
My use case involves validateStandardSchema. We have Zod schemas defined for our forms, and we are validating the forms with them using validateStandardSchema. We also have some of Angular's required() validators thrown in as well. The trouble is, we have a reused sub-schema that we need to add async validation to. This async Zod validation at some of the form leaf nodes (via async .superRefine() calls) causes the entire schema to return a promise instead of a synchronous value, and as such, Angular ignores the promise value whenever the form has other sync errors from the required() validators. To make matters worse, the Zod async validation is still run, but Angular is dropping the results on the floor.
So, my proposal is this: would it be possible/acceptable to add a configuration option to either the form itself, or to validateStandardSchema, to not ignore these async errors? I understand the reasoning to avoid expensive async validators when possible, but in this scenario, they aren't even being avoided, just ignored.
Proposed solution
Add a configuration option to FormOptions, called something like "processAsyncValidators", with possible values of "whenSyncValid" (default), and "always", which is consumed in validateAsync().
Alternatives considered