@@ -14,17 +14,28 @@ import {
1414 applyEach ,
1515 debounce ,
1616 disabled ,
17+ EmailValidationError ,
1718 form ,
1819 FormField ,
1920 hidden ,
21+ MaxDateValidationError ,
22+ MaxLengthValidationError ,
23+ MaxValidationError ,
24+ MinDateValidationError ,
25+ MinLengthValidationError ,
26+ MinValidationError ,
27+ NativeInputParseError ,
28+ PatternValidationError ,
2029 readonly ,
2130 required ,
2231 requiredError ,
32+ RequiredValidationError ,
2333 Schema ,
2434 schema ,
2535 SchemaOrSchemaFn ,
2636 SchemaPath ,
2737 SchemaPathTree ,
38+ StandardSchemaValidationError ,
2839 validate ,
2940 validateTree ,
3041 ValidationError ,
@@ -79,6 +90,60 @@ describe('FieldNode', () => {
7990 expect ( f . c ) . toBeUndefined ( ) ;
8091 } ) ;
8192
93+ it ( 'infers built-in error types from getError' , ( ) => {
94+ const f = form ( signal ( { a : 1 } ) , { injector : TestBed . inject ( Injector ) } ) ;
95+ const field = f . a ( ) ;
96+
97+ {
98+ const error = field . getError ( 'required' ) ;
99+ let t : ( RequiredValidationError & ValidationError . WithFieldTree ) | undefined = error ;
100+ }
101+ {
102+ const error = field . getError ( 'min' ) ;
103+ let t : ( MinValidationError & ValidationError . WithFieldTree ) | undefined = error ;
104+ }
105+ {
106+ const error = field . getError ( 'minDate' ) ;
107+ let t : ( MinDateValidationError & ValidationError . WithFieldTree ) | undefined = error ;
108+ }
109+ {
110+ const error = field . getError ( 'max' ) ;
111+ let t : ( MaxValidationError & ValidationError . WithFieldTree ) | undefined = error ;
112+ }
113+ {
114+ const error = field . getError ( 'maxDate' ) ;
115+ let t : ( MaxDateValidationError & ValidationError . WithFieldTree ) | undefined = error ;
116+ }
117+ {
118+ const error = field . getError ( 'minLength' ) ;
119+ let t : ( MinLengthValidationError & ValidationError . WithFieldTree ) | undefined = error ;
120+ }
121+ {
122+ const error = field . getError ( 'maxLength' ) ;
123+ let t : ( MaxLengthValidationError & ValidationError . WithFieldTree ) | undefined = error ;
124+ }
125+ {
126+ const error = field . getError ( 'pattern' ) ;
127+ let t : ( PatternValidationError & ValidationError . WithFieldTree ) | undefined = error ;
128+ }
129+ {
130+ const error = field . getError ( 'email' ) ;
131+ let t : ( EmailValidationError & ValidationError . WithFieldTree ) | undefined = error ;
132+ }
133+ {
134+ const error = field . getError ( 'standardSchema' ) ;
135+ let t : ( StandardSchemaValidationError & ValidationError . WithFieldTree ) | undefined = error ;
136+ }
137+ {
138+ const error = field . getError ( 'parse' ) ;
139+ let t : ( NativeInputParseError & ValidationError . WithFieldTree ) | undefined = error ;
140+ }
141+ {
142+ const error = field . getError ( 'custom' ) ;
143+ let t : ValidationError . WithFieldTree | undefined = error ;
144+ }
145+ } ) ;
146+
82147 it ( 'can get a child inside of a computed' , ( ) => {
83148 const f = form (
84149 signal ( {
0 commit comments