@angular/forms 21.0.0-next.2 → 21.0.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v21.0.0-next.2
2
+ * @license Angular v21.0.0-next.3
3
3
  * (c) 2010-2025 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -7,7 +7,7 @@
7
7
  import { HttpResourceRequest, HttpResourceOptions } from '@angular/common/http';
8
8
  import * as i0 from '@angular/core';
9
9
  import { ElementRef, WritableSignal, Signal, ResourceRef, InputSignal, ModelSignal, OutputRef, DestroyableInjector, Injector } from '@angular/core';
10
- import { ControlValueAccessor, NgControl, AbstractControl, ValidationErrors, FormControlStatus, ValidatorFn } from '@angular/forms';
10
+ import { ControlValueAccessor, NgControl } from '@angular/forms';
11
11
  import { StandardSchemaV1 } from '@standard-schema/spec';
12
12
 
13
13
  /**
@@ -24,6 +24,8 @@ import { StandardSchemaV1 } from '@standard-schema/spec';
24
24
  * 4. Provides a fake `NgControl` that implements a subset of the features available on the reactive
25
25
  * forms `NgControl`. This is provided to improve interoperability with controls designed to work
26
26
  * with reactive forms. It should not be used by controls written for signal forms.
27
+ *
28
+ * @experimental 21.0.0
27
29
  */
28
30
  declare class Control<T> {
29
31
  /** The injector for this component. */
@@ -71,19 +73,27 @@ declare class Control<T> {
71
73
  /**
72
74
  * Represents a property that may be defined on a field when it is created using a `property` rule
73
75
  * in the schema. A particular `Property` can only be defined on a particular field **once**.
76
+ *
77
+ * @experimental 21.0.0
74
78
  */
75
79
  declare class Property<TValue> {
76
80
  private brand;
77
81
  /** Use {@link createProperty}. */
78
82
  private constructor();
79
83
  }
80
- /** Creates a {@link Property}. */
84
+ /**
85
+ * Creates a {@link Property}.
86
+ *
87
+ * @experimental 21.0.0
88
+ */
81
89
  declare function createProperty<TValue>(): Property<TValue>;
82
90
  /**
83
91
  * Represents a property that is aggregated from multiple parts according to the property's reducer
84
92
  * function. A value can be contributed to the aggregated value for a field using an
85
93
  * `aggregateProperty` rule in the schema. There may be multiple rules in a schema that contribute
86
94
  * values to the same `AggregateProperty` of the same field.
95
+ *
96
+ * @experimental 21.0.0
87
97
  */
88
98
  declare class AggregateProperty<TAcc, TItem> {
89
99
  readonly reduce: (acc: TAcc, item: TItem) => TAcc;
@@ -97,50 +107,74 @@ declare class AggregateProperty<TAcc, TItem> {
97
107
  * the given `reduce` and `getInitial` functions.
98
108
  * @param reduce The reducer function.
99
109
  * @param getInitial A function that gets the initial value for the reduce operation.
110
+ *
111
+ * @experimental 21.0.0
100
112
  */
101
113
  declare function reducedProperty<TAcc, TItem>(reduce: (acc: TAcc, item: TItem) => TAcc, getInitial: () => TAcc): AggregateProperty<TAcc, TItem>;
102
114
  /**
103
115
  * Creates an aggregate property that reduces its individual values into a list.
116
+ *
117
+ * @experimental 21.0.0
104
118
  */
105
119
  declare function listProperty<TItem>(): AggregateProperty<TItem[], TItem | undefined>;
106
120
  /**
107
121
  * Creates an aggregate property that reduces its individual values by taking their min.
122
+ *
123
+ * @experimental 21.0.0
108
124
  */
109
125
  declare function minProperty(): AggregateProperty<number | undefined, number | undefined>;
110
126
  /**
111
127
  * Creates an aggregate property that reduces its individual values by taking their max.
128
+ *
129
+ * @experimental 21.0.0
112
130
  */
113
131
  declare function maxProperty(): AggregateProperty<number | undefined, number | undefined>;
114
132
  /**
115
133
  * Creates an aggregate property that reduces its individual values by logically or-ing them.
134
+ *
135
+ * @experimental 21.0.0
116
136
  */
117
137
  declare function orProperty(): AggregateProperty<boolean, boolean>;
118
138
  /**
119
139
  * Creates an aggregate property that reduces its individual values by logically and-ing them.
140
+ *
141
+ * @experimental 21.0.0
120
142
  */
121
143
  declare function andProperty(): AggregateProperty<boolean, boolean>;
122
144
  /**
123
145
  * An aggregate property representing whether the field is required.
146
+ *
147
+ * @experimental 21.0.0
124
148
  */
125
149
  declare const REQUIRED: AggregateProperty<boolean, boolean>;
126
150
  /**
127
151
  * An aggregate property representing the min value of the field.
152
+ *
153
+ * @experimental 21.0.0
128
154
  */
129
155
  declare const MIN: AggregateProperty<number | undefined, number | undefined>;
130
156
  /**
131
157
  * An aggregate property representing the max value of the field.
158
+ *
159
+ * @experimental 21.0.0
132
160
  */
133
161
  declare const MAX: AggregateProperty<number | undefined, number | undefined>;
134
162
  /**
135
163
  * An aggregate property representing the min length of the field.
164
+ *
165
+ * @experimental 21.0.0
136
166
  */
137
167
  declare const MIN_LENGTH: AggregateProperty<number | undefined, number | undefined>;
138
168
  /**
139
169
  * An aggregate property representing the max length of the field.
170
+ *
171
+ * @experimental 21.0.0
140
172
  */
141
173
  declare const MAX_LENGTH: AggregateProperty<number | undefined, number | undefined>;
142
174
  /**
143
175
  * An aggregate property representing the patterns the field must match.
176
+ *
177
+ * @experimental 21.0.0
144
178
  */
145
179
  declare const PATTERN: AggregateProperty<RegExp[], RegExp | undefined>;
146
180
 
@@ -154,6 +188,8 @@ interface ValidationErrorOptions {
154
188
  /**
155
189
  * A type that requires the given type `T` to have a `field` property.
156
190
  * @template T The type to add a `field` to.
191
+ *
192
+ * @experimental 21.0.0
157
193
  */
158
194
  type WithField<T> = T & {
159
195
  field: Field<unknown>;
@@ -161,6 +197,8 @@ type WithField<T> = T & {
161
197
  /**
162
198
  * A type that allows the given type `T` to optionally have a `field` property.
163
199
  * @template T The type to optionally add a `field` to.
200
+ *
201
+ * @experimental 21.0.0
164
202
  */
165
203
  type WithOptionalField<T> = Omit<T, 'field'> & {
166
204
  field?: Field<unknown>;
@@ -168,6 +206,8 @@ type WithOptionalField<T> = Omit<T, 'field'> & {
168
206
  /**
169
207
  * A type that ensures the given type `T` does not have a `field` property.
170
208
  * @template T The type to remove the `field` from.
209
+ *
210
+ * @experimental 21.0.0
171
211
  */
172
212
  type WithoutField<T> = T & {
173
213
  field: never;
@@ -175,109 +215,147 @@ type WithoutField<T> = T & {
175
215
  /**
176
216
  * Create a required error associated with the target field
177
217
  * @param options The validation error options
218
+ *
219
+ * @experimental 21.0.0
178
220
  */
179
221
  declare function requiredError(options: WithField<ValidationErrorOptions>): RequiredValidationError;
180
222
  /**
181
223
  * Create a required error
182
224
  * @param options The optional validation error options
225
+ *
226
+ * @experimental 21.0.0
183
227
  */
184
228
  declare function requiredError(options?: ValidationErrorOptions): WithoutField<RequiredValidationError>;
185
229
  /**
186
230
  * Create a min value error associated with the target field
187
231
  * @param min The min value constraint
188
232
  * @param options The validation error options
233
+ *
234
+ * @experimental 21.0.0
189
235
  */
190
236
  declare function minError(min: number, options: WithField<ValidationErrorOptions>): MinValidationError;
191
237
  /**
192
238
  * Create a min value error
193
239
  * @param min The min value constraint
194
240
  * @param options The optional validation error options
241
+ *
242
+ * @experimental 21.0.0
195
243
  */
196
244
  declare function minError(min: number, options?: ValidationErrorOptions): WithoutField<MinValidationError>;
197
245
  /**
198
246
  * Create a max value error associated with the target field
199
247
  * @param max The max value constraint
200
248
  * @param options The validation error options
249
+ *
250
+ * @experimental 21.0.0
201
251
  */
202
252
  declare function maxError(max: number, options: WithField<ValidationErrorOptions>): MaxValidationError;
203
253
  /**
204
254
  * Create a max value error
205
255
  * @param max The max value constraint
206
256
  * @param options The optional validation error options
257
+ *
258
+ * @experimental 21.0.0
207
259
  */
208
260
  declare function maxError(max: number, options?: ValidationErrorOptions): WithoutField<MaxValidationError>;
209
261
  /**
210
262
  * Create a minLength error associated with the target field
211
263
  * @param minLength The minLength constraint
212
264
  * @param options The validation error options
265
+ *
266
+ * @experimental 21.0.0
213
267
  */
214
268
  declare function minLengthError(minLength: number, options: WithField<ValidationErrorOptions>): MinLengthValidationError;
215
269
  /**
216
270
  * Create a minLength error
217
271
  * @param minLength The minLength constraint
218
272
  * @param options The optional validation error options
273
+ *
274
+ * @experimental 21.0.0
219
275
  */
220
276
  declare function minLengthError(minLength: number, options?: ValidationErrorOptions): WithoutField<MinLengthValidationError>;
221
277
  /**
222
278
  * Create a maxLength error associated with the target field
223
279
  * @param maxLength The maxLength constraint
224
280
  * @param options The validation error options
281
+ *
282
+ * @experimental 21.0.0
225
283
  */
226
284
  declare function maxLengthError(maxLength: number, options: WithField<ValidationErrorOptions>): MaxLengthValidationError;
227
285
  /**
228
286
  * Create a maxLength error
229
287
  * @param maxLength The maxLength constraint
230
288
  * @param options The optional validation error options
289
+ *
290
+ * @experimental 21.0.0
231
291
  */
232
292
  declare function maxLengthError(maxLength: number, options?: ValidationErrorOptions): WithoutField<MaxLengthValidationError>;
233
293
  /**
234
294
  * Create a pattern matching error associated with the target field
235
295
  * @param pattern The violated pattern
236
296
  * @param options The validation error options
297
+ *
298
+ * @experimental 21.0.0
237
299
  */
238
300
  declare function patternError(pattern: RegExp, options: WithField<ValidationErrorOptions>): PatternValidationError;
239
301
  /**
240
302
  * Create a pattern matching error
241
303
  * @param pattern The violated pattern
242
304
  * @param options The optional validation error options
305
+ *
306
+ * @experimental 21.0.0
243
307
  */
244
308
  declare function patternError(pattern: RegExp, options?: ValidationErrorOptions): WithoutField<PatternValidationError>;
245
309
  /**
246
310
  * Create an email format error associated with the target field
247
311
  * @param options The validation error options
312
+ *
313
+ * @experimental 21.0.0
248
314
  */
249
315
  declare function emailError(options: WithField<ValidationErrorOptions>): EmailValidationError;
250
316
  /**
251
317
  * Create an email format error
252
318
  * @param options The optional validation error options
319
+ *
320
+ * @experimental 21.0.0
253
321
  */
254
322
  declare function emailError(options?: ValidationErrorOptions): WithoutField<EmailValidationError>;
255
323
  /**
256
324
  * Create a standard schema issue error associated with the target field
257
325
  * @param issue The standard schema issue
258
326
  * @param options The validation error options
327
+ *
328
+ * @experimental 21.0.0
259
329
  */
260
330
  declare function standardSchemaError(issue: StandardSchemaV1.Issue, options: WithField<ValidationErrorOptions>): StandardSchemaValidationError;
261
331
  /**
262
332
  * Create a standard schema issue error
263
333
  * @param issue The standard schema issue
264
334
  * @param options The optional validation error options
335
+ *
336
+ * @experimental 21.0.0
265
337
  */
266
338
  declare function standardSchemaError(issue: StandardSchemaV1.Issue, options?: ValidationErrorOptions): WithoutField<StandardSchemaValidationError>;
267
339
  /**
268
340
  * Create a custom error associated with the target field
269
341
  * @param obj The object to create an error from
342
+ *
343
+ * @experimental 21.0.0
270
344
  */
271
345
  declare function customError<E extends Partial<ValidationError>>(obj: WithField<E>): CustomValidationError;
272
346
  /**
273
347
  * Create a custom error
274
348
  * @param obj The object to create an error from
349
+ *
350
+ * @experimental 21.0.0
275
351
  */
276
352
  declare function customError<E extends Partial<ValidationError>>(obj?: E): WithoutField<CustomValidationError>;
277
353
  /**
278
354
  * Common interface for all validation errors.
279
355
  *
280
356
  * Use the creation functions to create an instance (e.g. `requiredError`, `minError`, etc.).
357
+ *
358
+ * @experimental 21.0.0
281
359
  */
282
360
  interface ValidationError {
283
361
  /** Identifies the kind of error. */
@@ -289,6 +367,8 @@ interface ValidationError {
289
367
  }
290
368
  /**
291
369
  * A custom error that may contain additional properties
370
+ *
371
+ * @experimental 21.0.0
292
372
  */
293
373
  declare class CustomValidationError implements ValidationError {
294
374
  /** Brand the class to avoid Typescript structural matching */
@@ -308,6 +388,8 @@ declare class CustomValidationError implements ValidationError {
308
388
  /**
309
389
  * Internal version of `NgValidationError`, we create this separately so we can change its type on
310
390
  * the exported version to a type union of the possible sub-classes.
391
+ *
392
+ * @experimental 21.0.0
311
393
  */
312
394
  declare abstract class _NgValidationError implements ValidationError {
313
395
  /** Brand the class to avoid Typescript structural matching */
@@ -322,12 +404,16 @@ declare abstract class _NgValidationError implements ValidationError {
322
404
  }
323
405
  /**
324
406
  * An error used to indicate that a required field is empty.
407
+ *
408
+ * @experimental 21.0.0
325
409
  */
326
410
  declare class RequiredValidationError extends _NgValidationError {
327
411
  readonly kind = "required";
328
412
  }
329
413
  /**
330
414
  * An error used to indicate that a value is lower than the minimum allowed.
415
+ *
416
+ * @experimental 21.0.0
331
417
  */
332
418
  declare class MinValidationError extends _NgValidationError {
333
419
  readonly min: number;
@@ -336,6 +422,8 @@ declare class MinValidationError extends _NgValidationError {
336
422
  }
337
423
  /**
338
424
  * An error used to indicate that a value is higher than the maximum allowed.
425
+ *
426
+ * @experimental 21.0.0
339
427
  */
340
428
  declare class MaxValidationError extends _NgValidationError {
341
429
  readonly max: number;
@@ -344,6 +432,8 @@ declare class MaxValidationError extends _NgValidationError {
344
432
  }
345
433
  /**
346
434
  * An error used to indicate that a value is shorter than the minimum allowed length.
435
+ *
436
+ * @experimental 21.0.0
347
437
  */
348
438
  declare class MinLengthValidationError extends _NgValidationError {
349
439
  readonly minLength: number;
@@ -352,6 +442,8 @@ declare class MinLengthValidationError extends _NgValidationError {
352
442
  }
353
443
  /**
354
444
  * An error used to indicate that a value is longer than the maximum allowed length.
445
+ *
446
+ * @experimental 21.0.0
355
447
  */
356
448
  declare class MaxLengthValidationError extends _NgValidationError {
357
449
  readonly maxLength: number;
@@ -360,6 +452,8 @@ declare class MaxLengthValidationError extends _NgValidationError {
360
452
  }
361
453
  /**
362
454
  * An error used to indicate that a value does not match the required pattern.
455
+ *
456
+ * @experimental 21.0.0
363
457
  */
364
458
  declare class PatternValidationError extends _NgValidationError {
365
459
  readonly pattern: RegExp;
@@ -368,12 +462,16 @@ declare class PatternValidationError extends _NgValidationError {
368
462
  }
369
463
  /**
370
464
  * An error used to indicate that a value is not a valid email.
465
+ *
466
+ * @experimental 21.0.0
371
467
  */
372
468
  declare class EmailValidationError extends _NgValidationError {
373
469
  readonly kind = "email";
374
470
  }
375
471
  /**
376
472
  * An error used to indicate an issue validating against a standard schema.
473
+ *
474
+ * @experimental 21.0.0
377
475
  */
378
476
  declare class StandardSchemaValidationError extends _NgValidationError {
379
477
  readonly issue: StandardSchemaV1.Issue;
@@ -401,6 +499,8 @@ declare class StandardSchemaValidationError extends _NgValidationError {
401
499
  * }
402
500
  * }
403
501
  * ```
502
+ *
503
+ * @experimental 21.0.0
404
504
  */
405
505
  declare const NgValidationError: abstract new () => NgValidationError;
406
506
  type NgValidationError = RequiredValidationError | MinValidationError | MaxValidationError | MinLengthValidationError | MaxLengthValidationError | PatternValidationError | EmailValidationError | StandardSchemaValidationError;
@@ -412,6 +512,8 @@ declare const ɵɵTYPE: unique symbol;
412
512
  /**
413
513
  * Creates a type based on the given type T, but with all readonly properties made writable.
414
514
  * @template T The type to create a mutable version of.
515
+ *
516
+ * @experimental 21.0.0
415
517
  */
416
518
  type Mutable<T> = {
417
519
  -readonly [P in keyof T]: T[P];
@@ -419,10 +521,14 @@ type Mutable<T> = {
419
521
  /**
420
522
  * A type that represents either a single value of type `T` or a readonly array of `T`.
421
523
  * @template T The type of the value(s).
524
+ *
525
+ * @experimental 21.0.0
422
526
  */
423
527
  type OneOrMany<T> = T | readonly T[];
424
528
  /**
425
529
  * The kind of `FieldPath` (`Root`, `Child` of another `FieldPath`, or `Item` in a `FieldPath` array)
530
+ *
531
+ * @experimental 21.0.0
426
532
  */
427
533
  declare namespace PathKind {
428
534
  /**
@@ -452,10 +558,14 @@ declare namespace PathKind {
452
558
  type PathKind = PathKind.Root | PathKind.Child | PathKind.Item;
453
559
  /**
454
560
  * A status indicating whether a field is unsubmitted, submitted, or currently submitting.
561
+ *
562
+ * @experimental 21.0.0
455
563
  */
456
564
  type SubmittedStatus = 'unsubmitted' | 'submitted' | 'submitting';
457
565
  /**
458
566
  * A reason for a field's disablement.
567
+ *
568
+ * @experimental 21.0.0
459
569
  */
460
570
  interface DisabledReason {
461
571
  /** The field that is disabled. */
@@ -463,7 +573,11 @@ interface DisabledReason {
463
573
  /** A user-facing message describing the reason for the disablement. */
464
574
  readonly message?: string;
465
575
  }
466
- /** The absence of an error which indicates a successful validation result. */
576
+ /**
577
+ * The absence of an error which indicates a successful validation result.
578
+ *
579
+ * @experimental 21.0.0
580
+ */
467
581
  type ValidationSuccess = null | undefined | void;
468
582
  /**
469
583
  * The result of running a field validation function.
@@ -475,6 +589,8 @@ type ValidationSuccess = null | undefined | void;
475
589
  * being validated.
476
590
  *
477
591
  * @template E the type of error (defaults to {@link ValidationError}).
592
+ *
593
+ * @experimental 21.0.0
478
594
  */
479
595
  type FieldValidationResult<E extends ValidationError = ValidationError> = ValidationSuccess | OneOrMany<WithoutField<E>>;
480
596
  /**
@@ -487,6 +603,8 @@ type FieldValidationResult<E extends ValidationError = ValidationError> = Valida
487
603
  * 4. A list of {@link ValidationError} with or without fields to indicate multiple errors.
488
604
  *
489
605
  * @template E the type of error (defaults to {@link ValidationError}).
606
+ *
607
+ * @experimental 21.0.0
490
608
  */
491
609
  type TreeValidationResult<E extends ValidationError = ValidationError> = ValidationSuccess | OneOrMany<WithOptionalField<E>>;
492
610
  /**
@@ -498,6 +616,8 @@ type TreeValidationResult<E extends ValidationError = ValidationError> = Validat
498
616
  * 3. A list of {@link ValidationError} with fields to indicate multiple errors.
499
617
  *
500
618
  * @template E the type of error (defaults to {@link ValidationError}).
619
+ *
620
+ * @experimental 21.0.0
501
621
  */
502
622
  type ValidationResult<E extends ValidationError = ValidationError> = ValidationSuccess | OneOrMany<E>;
503
623
  /**
@@ -508,6 +628,8 @@ type ValidationResult<E extends ValidationError = ValidationError> = ValidationS
508
628
  * 5. 'pending' if the validation is not yet resolved.
509
629
  *
510
630
  * @template E the type of error (defaults to {@link ValidationError}).
631
+ *
632
+ * @experimental 21.0.0
511
633
  */
512
634
  type AsyncValidationResult<E extends ValidationError = ValidationError> = ValidationResult<E> | 'pending';
513
635
  /**
@@ -519,12 +641,16 @@ type AsyncValidationResult<E extends ValidationError = ValidationError> = Valida
519
641
  *
520
642
  * @template TValue The type of the data which the field is wrapped around.
521
643
  * @template TKey The type of the property key which this field resides under in its parent.
644
+ *
645
+ * @experimental 21.0.0
522
646
  */
523
647
  type Field<TValue, TKey extends string | number = string | number> = (() => FieldState<TValue, TKey>) & (TValue extends Array<infer U> ? ReadonlyArrayLike<MaybeField<U, number>> : TValue extends Record<string, any> ? Subfields<TValue> : unknown);
524
648
  /**
525
649
  * The sub-fields that a user can navigate to from a `Field<TValue>`.
526
650
  *
527
651
  * @template TValue The type of the data which the parent field is wrapped around.
652
+ *
653
+ * @experimental 21.0.0
528
654
  */
529
655
  type Subfields<TValue> = {
530
656
  readonly [K in keyof TValue as TValue[K] extends Function ? never : K]: MaybeField<TValue[K], string>;
@@ -533,6 +659,8 @@ type Subfields<TValue> = {
533
659
  * An iterable object with the same shape as a readonly array.
534
660
  *
535
661
  * @template T The array item type.
662
+ *
663
+ * @experimental 21.0.0
536
664
  */
537
665
  type ReadonlyArrayLike<T> = Pick<ReadonlyArray<T>, number | 'length' | typeof Symbol.iterator>;
538
666
  /**
@@ -544,11 +672,15 @@ type ReadonlyArrayLike<T> = Pick<ReadonlyArray<T>, number | 'length' | typeof Sy
544
672
  *
545
673
  * @template TValue The type of the data which the field is wrapped around.
546
674
  * @template TKey The type of the property key which this field resides under in its parent.
675
+ *
676
+ * @experimental 21.0.0
547
677
  */
548
678
  type MaybeField<TValue, TKey extends string | number = string | number> = (TValue & undefined) | Field<Exclude<TValue, undefined>, TKey>;
549
679
  /**
550
680
  * Contains all of the state (e.g. value, statuses, etc.) associated with a `Field`, exposed as
551
681
  * signals.
682
+ *
683
+ * @experimental 21.0.0
552
684
  */
553
685
  interface FieldState<TValue, TKey extends string | number = string | number> {
554
686
  /**
@@ -678,6 +810,8 @@ interface FieldState<TValue, TKey extends string | number = string | number> {
678
810
  *
679
811
  * @template TValue The type of the data which the form is wrapped around.
680
812
  * @template TPathKind The kind of path (root field, child field, or item of an array)
813
+ *
814
+ * @experimental 21.0.0
681
815
  */
682
816
  type FieldPath<TValue, TPathKind extends PathKind = PathKind.Root> = {
683
817
  [ɵɵTYPE]: [TValue, TPathKind];
@@ -693,12 +827,16 @@ type FieldPath<TValue, TPathKind extends PathKind = PathKind.Root> = {
693
827
  *
694
828
  * @template TValue The type of the data which the field is wrapped around.
695
829
  * @template TPathKind The kind of path (root field, child field, or item of an array)
830
+ *
831
+ * @experimental 21.0.0
696
832
  */
697
833
  type MaybeFieldPath<TValue, TPathKind extends PathKind = PathKind.Root> = (TValue & undefined) | FieldPath<Exclude<TValue, undefined>, TPathKind>;
698
834
  /**
699
835
  * Defines logic for a form.
700
836
  *
701
837
  * @template TValue The type of data stored in the form that this schema is attached to.
838
+ *
839
+ * @experimental 21.0.0
702
840
  */
703
841
  type Schema<in TValue> = {
704
842
  [ɵɵTYPE]: SchemaFn<TValue, PathKind.Root>;
@@ -708,6 +846,8 @@ type Schema<in TValue> = {
708
846
  *
709
847
  * @template TValue The type of data stored in the form that this schema function is attached to.
710
848
  * @template TPathKind The kind of path this schema function can be bound to.
849
+ *
850
+ * @experimental 21.0.0
711
851
  */
712
852
  type SchemaFn<TValue, TPathKind extends PathKind = PathKind.Root> = (p: FieldPath<TValue, TPathKind>) => void;
713
853
  /**
@@ -715,6 +855,8 @@ type SchemaFn<TValue, TPathKind extends PathKind = PathKind.Root> = (p: FieldPat
715
855
  *
716
856
  * @template TValue The type of data stored in the form that this schema function is attached to.
717
857
  * @template TPathKind The kind of path this schema function can be bound to.
858
+ *
859
+ * @experimental 21.0.0
718
860
  */
719
861
  type SchemaOrSchemaFn<TValue, TPathKind extends PathKind = PathKind.Root> = Schema<TValue> | SchemaFn<TValue, TPathKind>;
720
862
  /**
@@ -724,6 +866,8 @@ type SchemaOrSchemaFn<TValue, TPathKind extends PathKind = PathKind.Root> = Sche
724
866
  * @template TValue The data type for the field the logic is bound to.
725
867
  * @template TReturn The type of the result returned by the logic function.
726
868
  * @template TPathKind The kind of path the logic is applied to (root field, child field, or item of an array)
869
+ *
870
+ * @experimental 21.0.0
727
871
  */
728
872
  type LogicFn<TValue, TReturn, TPathKind extends PathKind = PathKind.Root> = (ctx: FieldContext<TValue, TPathKind>) => TReturn;
729
873
  /**
@@ -732,6 +876,8 @@ type LogicFn<TValue, TReturn, TPathKind extends PathKind = PathKind.Root> = (ctx
732
876
  *
733
877
  * @template TValue The type of value stored in the field being validated
734
878
  * @template TPathKind The kind of path being validated (root field, child field, or item of an array)
879
+ *
880
+ * @experimental 21.0.0
735
881
  */
736
882
  type FieldValidator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicFn<TValue, FieldValidationResult, TPathKind>;
737
883
  /**
@@ -740,6 +886,8 @@ type FieldValidator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicF
740
886
  *
741
887
  * @template TValue The type of value stored in the field being validated
742
888
  * @template TPathKind The kind of path being validated (root field, child field, or item of an array)
889
+ *
890
+ * @experimental 21.0.0
743
891
  */
744
892
  type TreeValidator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicFn<TValue, TreeValidationResult, TPathKind>;
745
893
  /**
@@ -749,15 +897,21 @@ type TreeValidator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicFn
749
897
  *
750
898
  * @template TValue The type of value stored in the field being validated
751
899
  * @template TPathKind The kind of path being validated (root field, child field, or item of an array)
900
+ *
901
+ * @experimental 21.0.0
752
902
  */
753
903
  type Validator<TValue, TPathKind extends PathKind = PathKind.Root> = LogicFn<TValue, ValidationResult, TPathKind>;
754
904
  /**
755
905
  * Provides access to the state of the current field as well as functions that can be used to look
756
906
  * up state of other fields based on a `FieldPath`.
907
+ *
908
+ * @experimental 21.0.0
757
909
  */
758
910
  type FieldContext<TValue, TPathKind extends PathKind = PathKind.Root> = TPathKind extends PathKind.Item ? ItemFieldContext<TValue> : TPathKind extends PathKind.Child ? ChildFieldContext<TValue> : RootFieldContext<TValue>;
759
911
  /**
760
912
  * The base field context that is available for all fields.
913
+ *
914
+ * @experimental 21.0.0
761
915
  */
762
916
  interface RootFieldContext<TValue> {
763
917
  /** A signal containing the value of the current field. */
@@ -775,6 +929,8 @@ interface RootFieldContext<TValue> {
775
929
  }
776
930
  /**
777
931
  * Field context that is available for all fields that are a child of another field.
932
+ *
933
+ * @experimental 21.0.0
778
934
  */
779
935
  interface ChildFieldContext<TValue> extends RootFieldContext<TValue> {
780
936
  /** The key of the current field in its parent field. */
@@ -782,6 +938,8 @@ interface ChildFieldContext<TValue> extends RootFieldContext<TValue> {
782
938
  }
783
939
  /**
784
940
  * Field context that is available for all fields that are an item in an array field.
941
+ *
942
+ * @experimental 21.0.0
785
943
  */
786
944
  interface ItemFieldContext<TValue> extends ChildFieldContext<TValue> {
787
945
  /** The index of the current field in its parent field. */
@@ -801,6 +959,8 @@ interface ItemFieldContext<TValue> extends ChildFieldContext<TValue> {
801
959
  * @template TValue The type of value stored in the field being validated.
802
960
  * @template TResult The type of result returned by the async operation
803
961
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
962
+ *
963
+ * @experimental 21.0.0
804
964
  */
805
965
  type MapToErrorsFn<TValue, TResult, TPathKind extends PathKind = PathKind.Root> = (result: TResult, ctx: FieldContext<TValue, TPathKind>) => TreeValidationResult;
806
966
  /**
@@ -811,6 +971,8 @@ type MapToErrorsFn<TValue, TResult, TPathKind extends PathKind = PathKind.Root>
811
971
  * @template TParams The type of parameters to the resource.
812
972
  * @template TResult The type of result returned by the resource
813
973
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
974
+ *
975
+ * @experimental 21.0.0
814
976
  */
815
977
  interface AsyncValidatorOptions<TValue, TParams, TResult, TPathKind extends PathKind = PathKind.Root> {
816
978
  /**
@@ -849,6 +1011,8 @@ interface AsyncValidatorOptions<TValue, TParams, TResult, TPathKind extends Path
849
1011
  * @template TValue The type of value stored in the field being validated.
850
1012
  * @template TResult The type of result returned by the httpResource
851
1013
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
1014
+ *
1015
+ * @experimental 21.0.0
852
1016
  */
853
1017
  interface HttpValidatorOptions<TValue, TResult, TPathKind extends PathKind = PathKind.Root> {
854
1018
  /**
@@ -886,6 +1050,8 @@ interface HttpValidatorOptions<TValue, TResult, TPathKind extends PathKind = Pat
886
1050
  * @template TParams The type of parameters to the resource.
887
1051
  * @template TResult The type of result returned by the resource
888
1052
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
1053
+ *
1054
+ * @experimental 21.0.0
889
1055
  */
890
1056
  declare function validateAsync<TValue, TParams, TResult, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, opts: AsyncValidatorOptions<TValue, TParams, TResult, TPathKind>): void;
891
1057
  /**
@@ -897,10 +1063,16 @@ declare function validateAsync<TValue, TParams, TResult, TPathKind extends PathK
897
1063
  * @template TValue The type of value stored in the field being validated.
898
1064
  * @template TResult The type of result returned by the httpResource
899
1065
  * @template TPathKind The kind of path being validated (a root path, child path, or item of an array)
1066
+ *
1067
+ * @experimental 21.0.0
900
1068
  */
901
1069
  declare function validateHttp<TValue, TResult = unknown, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, opts: HttpValidatorOptions<TValue, TResult, TPathKind>): void;
902
1070
 
903
- /** The base set of properties shared by all form control contracts. */
1071
+ /**
1072
+ * The base set of properties shared by all form control contracts.
1073
+ *
1074
+ * @experimental 21.0.0
1075
+ */
904
1076
  interface FormUiControl {
905
1077
  /**
906
1078
  * An input to receive the errors for the field. If implemented, the `Control` directive will
@@ -992,6 +1164,8 @@ interface FormUiControl {
992
1164
  * `Control` directive.
993
1165
  *
994
1166
  * @template TValue The type of `Field` that the implementing component can edit.
1167
+ *
1168
+ * @experimental 21.0.0
995
1169
  */
996
1170
  interface FormValueControl<TValue> extends FormUiControl {
997
1171
  /**
@@ -1013,6 +1187,8 @@ interface FormValueControl<TValue> extends FormUiControl {
1013
1187
  * Many of the properties declared on this contract are optional. They do not need to be
1014
1188
  * implemented, but if they are will be kept in sync with the field state of the field bound to the
1015
1189
  * `Control` directive.
1190
+ *
1191
+ * @experimental 21.0.0
1016
1192
  */
1017
1193
  interface FormCheckboxControl extends FormUiControl {
1018
1194
  /**
@@ -1037,6 +1213,8 @@ interface FormCheckboxControl extends FormUiControl {
1037
1213
  * and `false` when it is not disabled.
1038
1214
  * @template TValue The type of value stored in the field the logic is bound to.
1039
1215
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1216
+ *
1217
+ * @experimental 21.0.0
1040
1218
  */
1041
1219
  declare function disabled<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, logic?: string | NoInfer<LogicFn<TValue, boolean | string, TPathKind>>): void;
1042
1220
  /**
@@ -1047,6 +1225,8 @@ declare function disabled<TValue, TPathKind extends PathKind = PathKind.Root>(pa
1047
1225
  * @param logic A reactive function that returns `true` when the field is readonly.
1048
1226
  * @template TValue The type of value stored in the field the logic is bound to.
1049
1227
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1228
+ *
1229
+ * @experimental 21.0.0
1050
1230
  */
1051
1231
  declare function readonly<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, logic?: NoInfer<LogicFn<TValue, boolean, TPathKind>>): void;
1052
1232
  /**
@@ -1065,6 +1245,8 @@ declare function readonly<TValue, TPathKind extends PathKind = PathKind.Root>(pa
1065
1245
  * @param logic A reactive function that returns `true` when the field is hidden.
1066
1246
  * @template TValue The type of value stored in the field the logic is bound to.
1067
1247
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1248
+ *
1249
+ * @experimental 21.0.0
1068
1250
  */
1069
1251
  declare function hidden<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, logic: NoInfer<LogicFn<TValue, boolean, TPathKind>>): void;
1070
1252
  /**
@@ -1074,6 +1256,8 @@ declare function hidden<TValue, TPathKind extends PathKind = PathKind.Root>(path
1074
1256
  * @param logic A `Validator` that returns the current validation errors.
1075
1257
  * @template TValue The type of value stored in the field the logic is bound to.
1076
1258
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1259
+ *
1260
+ * @experimental 21.0.0
1077
1261
  */
1078
1262
  declare function validate<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, logic: NoInfer<FieldValidator<TValue, TPathKind>>): void;
1079
1263
  /**
@@ -1084,6 +1268,8 @@ declare function validate<TValue, TPathKind extends PathKind = PathKind.Root>(pa
1084
1268
  * Errors returned by the validator may specify a target field to indicate an error on a child field.
1085
1269
  * @template TValue The type of value stored in the field the logic is bound to.
1086
1270
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1271
+ *
1272
+ * @experimental 21.0.0
1087
1273
  */
1088
1274
  declare function validateTree<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, logic: NoInfer<TreeValidator<TValue, TPathKind>>): void;
1089
1275
  /**
@@ -1095,6 +1281,8 @@ declare function validateTree<TValue, TPathKind extends PathKind = PathKind.Root
1095
1281
  * @template TValue The type of value stored in the field the logic is bound to.
1096
1282
  * @template TPropItem The type of value the property aggregates over.
1097
1283
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
1284
+ *
1285
+ * @experimental 21.0.0
1098
1286
  */
1099
1287
  declare function aggregateProperty<TValue, TPropItem, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, prop: AggregateProperty<any, TPropItem>, logic: NoInfer<LogicFn<TValue, TPropItem, TPathKind>>): void;
1100
1288
  /**
@@ -1104,6 +1292,8 @@ declare function aggregateProperty<TValue, TPropItem, TPathKind extends PathKind
1104
1292
  * @param factory A factory function that creates the value for the property.
1105
1293
  * This function is **not** reactive. It is run once when the field is created.
1106
1294
  * @returns The newly created property
1295
+ *
1296
+ * @experimental 21.0.0
1107
1297
  */
1108
1298
  declare function property<TValue, TData, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, factory: (ctx: FieldContext<TValue, TPathKind>) => TData): Property<TData>;
1109
1299
  /**
@@ -1114,6 +1304,8 @@ declare function property<TValue, TData, TPathKind extends PathKind = PathKind.R
1114
1304
  * @param factory A factory function that creates the value for the property.
1115
1305
  * This function is **not** reactive. It is run once when the field is created.
1116
1306
  * @returns The given property
1307
+ *
1308
+ * @experimental 21.0.0
1117
1309
  */
1118
1310
  declare function property<TValue, TData, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, prop: Property<TData>, factory: (ctx: FieldContext<TValue, TPathKind>) => TData): Property<TData>;
1119
1311
 
@@ -1973,7 +2165,11 @@ interface FieldAdapter {
1973
2165
  newRoot<TValue>(fieldManager: FormFieldManager, model: WritableSignal<TValue>, pathNode: FieldPathNode, adapter: FieldAdapter): FieldNode;
1974
2166
  }
1975
2167
 
1976
- /** Options that may be specified when creating a form. */
2168
+ /**
2169
+ * Options that may be specified when creating a form.
2170
+ *
2171
+ * @experimental 21.0.0
2172
+ */
1977
2173
  interface FormOptions {
1978
2174
  /**
1979
2175
  * The injector to use for dependency injection. If this is not provided, the injector for the
@@ -2009,6 +2205,8 @@ interface FormOptions {
2009
2205
  * the model.
2010
2206
  * @return A `Field` representing a form around the data model.
2011
2207
  * @template TValue The type of the data model.
2208
+ *
2209
+ * @experimental 21.0.0
2012
2210
  */
2013
2211
  declare function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
2014
2212
  /**
@@ -2052,6 +2250,8 @@ declare function form<TValue>(model: WritableSignal<TValue>): Field<TValue>;
2052
2250
  * 2. The form options
2053
2251
  * @return A `Field` representing a form around the data model
2054
2252
  * @template TValue The type of the data model.
2253
+ *
2254
+ * @experimental 21.0.0
2055
2255
  */
2056
2256
  declare function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: SchemaOrSchemaFn<TValue> | FormOptions): Field<TValue>;
2057
2257
  /**
@@ -2093,6 +2293,8 @@ declare function form<TValue>(model: WritableSignal<TValue>, schemaOrOptions: Sc
2093
2293
  * @param options The form options
2094
2294
  * @return A `Field` representing a form around the data model.
2095
2295
  * @template TValue The type of the data model.
2296
+ *
2297
+ * @experimental 21.0.0
2096
2298
  */
2097
2299
  declare function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSchemaFn<TValue>, options: FormOptions): Field<TValue>;
2098
2300
  /**
@@ -2129,6 +2331,8 @@ declare function form<TValue>(model: WritableSignal<TValue>, schema: SchemaOrSch
2129
2331
  * @param schema A schema for an element of the array, or function that binds logic to an
2130
2332
  * element of the array.
2131
2333
  * @template TValue The data type of the item field to apply the schema to.
2334
+ *
2335
+ * @experimental 21.0.0
2132
2336
  */
2133
2337
  declare function applyEach<TValue>(path: FieldPath<TValue[]>, schema: NoInfer<SchemaOrSchemaFn<TValue, PathKind.Item>>): void;
2134
2338
  /**
@@ -2148,6 +2352,8 @@ declare function applyEach<TValue>(path: FieldPath<TValue[]>, schema: NoInfer<Sc
2148
2352
  * @param path The target path to apply the schema to.
2149
2353
  * @param schema The schema to apply to the property
2150
2354
  * @template TValue The data type of the field to apply the schema to.
2355
+ *
2356
+ * @experimental 21.0.0
2151
2357
  */
2152
2358
  declare function apply<TValue>(path: FieldPath<TValue>, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;
2153
2359
  /**
@@ -2157,6 +2363,8 @@ declare function apply<TValue>(path: FieldPath<TValue>, schema: NoInfer<SchemaOr
2157
2363
  * @param logic A `LogicFn<T, boolean>` that returns `true` when the schema should be applied.
2158
2364
  * @param schema The schema to apply to the field when the `logic` function returns `true`.
2159
2365
  * @template TValue The data type of the field to apply the schema to.
2366
+ *
2367
+ * @experimental 21.0.0
2160
2368
  */
2161
2369
  declare function applyWhen<TValue>(path: FieldPath<TValue>, logic: LogicFn<TValue, boolean>, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;
2162
2370
  /**
@@ -2168,6 +2376,8 @@ declare function applyWhen<TValue>(path: FieldPath<TValue>, logic: LogicFn<TValu
2168
2376
  * @param schema The schema to apply to the field when `predicate` returns `true`.
2169
2377
  * @template TValue The data type of the field to apply the schema to.
2170
2378
  * @template TNarrowed The data type of the schema (a narrowed type of TValue).
2379
+ *
2380
+ * @experimental 21.0.0
2171
2381
  */
2172
2382
  declare function applyWhenValue<TValue, TNarrowed extends TValue>(path: FieldPath<TValue>, predicate: (value: TValue) => value is TNarrowed, schema: SchemaOrSchemaFn<TNarrowed>): void;
2173
2383
  /**
@@ -2178,6 +2388,8 @@ declare function applyWhenValue<TValue, TNarrowed extends TValue>(path: FieldPat
2178
2388
  * should be applied.
2179
2389
  * @param schema The schema to apply to the field when `predicate` returns `true`.
2180
2390
  * @template TValue The data type of the field to apply the schema to.
2391
+ *
2392
+ * @experimental 21.0.0
2181
2393
  */
2182
2394
  declare function applyWhenValue<TValue>(path: FieldPath<TValue>, predicate: (value: TValue) => boolean, schema: NoInfer<SchemaOrSchemaFn<TValue>>): void;
2183
2395
  /**
@@ -2210,6 +2422,8 @@ declare function applyWhenValue<TValue>(path: FieldPath<TValue>, predicate: (val
2210
2422
  * @param action An asynchronous action used to submit the field. The action may return server
2211
2423
  * errors.
2212
2424
  * @template TValue The data type of the field being submitted.
2425
+ *
2426
+ * @experimental 21.0.0
2213
2427
  */
2214
2428
  declare function submit<TValue>(form: Field<TValue>, action: (form: Field<TValue>) => Promise<TreeValidationResult>): Promise<void>;
2215
2429
  /**
@@ -2217,6 +2431,8 @@ declare function submit<TValue>(form: Field<TValue>, action: (form: Field<TValue
2217
2431
  * @param fn A **non-reactive** function that sets up reactive logic rules for the form.
2218
2432
  * @returns A schema object that implements the given logic.
2219
2433
  * @template TValue The value type of a `Field` that this schema binds to.
2434
+ *
2435
+ * @experimental 21.0.0
2220
2436
  */
2221
2437
  declare function schema<TValue>(fn: SchemaFn<TValue>): Schema<TValue>;
2222
2438
 
@@ -2249,6 +2465,8 @@ type BaseValidatorConfig<TValue, TPathKind extends PathKind = PathKind.Root> = {
2249
2465
  * - `error`: Custom validation error(s) to be used instead of the default `ValidationError.email()`
2250
2466
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2251
2467
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2468
+ *
2469
+ * @experimental 21.0.0
2252
2470
  */
2253
2471
  declare function email<TPathKind extends PathKind = PathKind.Root>(path: FieldPath<string, TPathKind>, config?: BaseValidatorConfig<string, TPathKind>): void;
2254
2472
 
@@ -2264,6 +2482,8 @@ declare function email<TPathKind extends PathKind = PathKind.Root>(path: FieldPa
2264
2482
  * - `error`: Custom validation error(s) to be used instead of the default `ValidationError.max(maxValue)`
2265
2483
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2266
2484
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2485
+ *
2486
+ * @experimental 21.0.0
2267
2487
  */
2268
2488
  declare function max<TPathKind extends PathKind = PathKind.Root>(path: FieldPath<number, TPathKind>, maxValue: number | LogicFn<number, number | undefined, TPathKind>, config?: BaseValidatorConfig<number, TPathKind>): void;
2269
2489
 
@@ -2280,6 +2500,8 @@ declare function max<TPathKind extends PathKind = PathKind.Root>(path: FieldPath
2280
2500
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2281
2501
  * @template TValue The type of value stored in the field the logic is bound to.
2282
2502
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2503
+ *
2504
+ * @experimental 21.0.0
2283
2505
  */
2284
2506
  declare function maxLength<TValue extends ValueWithLengthOrSize, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, maxLength: number | LogicFn<TValue, number | undefined, TPathKind>, config?: BaseValidatorConfig<TValue, TPathKind>): void;
2285
2507
 
@@ -2295,6 +2517,8 @@ declare function maxLength<TValue extends ValueWithLengthOrSize, TPathKind exten
2295
2517
  * - `error`: Custom validation error(s) to be used instead of the default `ValidationError.min(minValue)`
2296
2518
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2297
2519
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2520
+ *
2521
+ * @experimental 21.0.0
2298
2522
  */
2299
2523
  declare function min<TPathKind extends PathKind = PathKind.Root>(path: FieldPath<number, TPathKind>, minValue: number | LogicFn<number, number | undefined, TPathKind>, config?: BaseValidatorConfig<number, TPathKind>): void;
2300
2524
 
@@ -2311,6 +2535,8 @@ declare function min<TPathKind extends PathKind = PathKind.Root>(path: FieldPath
2311
2535
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2312
2536
  * @template TValue The type of value stored in the field the logic is bound to.
2313
2537
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2538
+ *
2539
+ * @experimental 21.0.0
2314
2540
  */
2315
2541
  declare function minLength<TValue extends ValueWithLengthOrSize, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, minLength: number | LogicFn<TValue, number | undefined, TPathKind>, config?: BaseValidatorConfig<TValue, TPathKind>): void;
2316
2542
 
@@ -2325,6 +2551,8 @@ declare function minLength<TValue extends ValueWithLengthOrSize, TPathKind exten
2325
2551
  * - `error`: Custom validation error(s) to be used instead of the default `ValidationError.pattern(pattern)`
2326
2552
  * or a function that receives the `FieldContext` and returns custom validation error(s).
2327
2553
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2554
+ *
2555
+ * @experimental 21.0.0
2328
2556
  */
2329
2557
  declare function pattern<TPathKind extends PathKind = PathKind.Root>(path: FieldPath<string, TPathKind>, pattern: RegExp | LogicFn<string | undefined, RegExp | undefined, TPathKind>, config?: BaseValidatorConfig<string, TPathKind>): void;
2330
2558
 
@@ -2341,42 +2569,45 @@ declare function pattern<TPathKind extends PathKind = PathKind.Root>(path: Field
2341
2569
  * - `when`: A function that receives the `FieldContext` and returns true if the field is required
2342
2570
  * @template TValue The type of value stored in the field the logic is bound to.
2343
2571
  * @template TPathKind The kind of path the logic is bound to (a root path, child path, or item of an array)
2572
+ *
2573
+ * @experimental 21.0.0
2344
2574
  */
2345
2575
  declare function required<TValue, TPathKind extends PathKind = PathKind.Root>(path: FieldPath<TValue, TPathKind>, config?: BaseValidatorConfig<TValue, TPathKind> & {
2346
2576
  when?: NoInfer<LogicFn<TValue, boolean, TPathKind>>;
2347
2577
  }): void;
2348
2578
 
2349
2579
  /**
2350
- * Properties of both NgControl & AbstractControl that are supported by the InteropNgControl.
2351
- */
2352
- type InteropSharedKeys = 'value' | 'valid' | 'invalid' | 'touched' | 'untouched' | 'disabled' | 'enabled' | 'errors' | 'pristine' | 'dirty' | 'status';
2353
- /**
2354
- * A fake version of `NgControl` provided by the `Control` directive. This allows interoperability
2355
- * with a wider range of components designed to work with reactive forms, in particular ones that
2356
- * inject the `NgControl`. The interop control does not implement *all* properties and methods of
2357
- * the real `NgControl`, but does implement some of the most commonly used ones that have a clear
2358
- * equivalent in signal forms.
2359
- */
2360
- declare class InteropNgControl implements Pick<NgControl, InteropSharedKeys | 'control' | 'valueAccessor'>, Pick<AbstractControl<unknown>, InteropSharedKeys | 'hasValidator'> {
2361
- protected field: () => FieldState<unknown>;
2362
- constructor(field: () => FieldState<unknown>);
2363
- readonly control: AbstractControl<any, any>;
2364
- get value(): any;
2365
- get valid(): boolean;
2366
- get invalid(): boolean;
2367
- get pending(): boolean | null;
2368
- get disabled(): boolean;
2369
- get enabled(): boolean;
2370
- get errors(): ValidationErrors | null;
2371
- get pristine(): boolean;
2372
- get dirty(): boolean;
2373
- get touched(): boolean;
2374
- get untouched(): boolean;
2375
- get status(): FormControlStatus;
2376
- valueAccessor: ControlValueAccessor | null;
2377
- hasValidator(validator: ValidatorFn): boolean;
2378
- updateValueAndValidity(): void;
2379
- }
2580
+ * Utility type that removes a string index key when its value is `unknown`,
2581
+ * i.e. `{[key: string]: unknown}`. It allows specific string keys to pass through, even if their
2582
+ * value is `unknown`, e.g. `{key: unknown}`.
2583
+ *
2584
+ * @experimental 21.0.0
2585
+ */
2586
+ type RemoveStringIndexUnknownKey<K, V> = string extends K ? unknown extends V ? never : K : K;
2587
+ /**
2588
+ * Utility type that recursively ignores unknown string index properties on the given object.
2589
+ * We use this on the `TSchema` type in `validateStandardSchema` in order to accommodate Zod's
2590
+ * `looseObject` which includes `{[key: string]: unknown}` as part of the type.
2591
+ *
2592
+ * @experimental 21.0.0
2593
+ */
2594
+ type IgnoreUnknownProperties<T> = T extends Record<PropertyKey, unknown> ? {
2595
+ [K in keyof T as RemoveStringIndexUnknownKey<K, T[K]>]: IgnoreUnknownProperties<T[K]>;
2596
+ } : T;
2597
+ /**
2598
+ * Validates a field using a `StandardSchemaV1` compatible validator (e.g. a Zod validator).
2599
+ *
2600
+ * See https://github.com/standard-schema/standard-schema for more about standard schema.
2601
+ *
2602
+ * @param path The `FieldPath` to the field to validate.
2603
+ * @param schema The standard schema compatible validator to use for validation.
2604
+ * @template TSchema The type validated by the schema. This may be either the full `TValue` type,
2605
+ * or a partial of it.
2606
+ * @template TValue The type of value stored in the field being validated.
2607
+ *
2608
+ * @experimental 21.0.0
2609
+ */
2610
+ declare function validateStandardSchema<TSchema, TValue extends IgnoreUnknownProperties<TSchema>>(path: FieldPath<TValue>, schema: StandardSchemaV1<TSchema>): void;
2380
2611
 
2381
- export { AggregateProperty, Control, CustomValidationError, EmailValidationError, InteropNgControl, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PathKind, PatternValidationError, Property, REQUIRED, RequiredValidationError, StandardSchemaValidationError, aggregateProperty, andProperty, apply, applyEach, applyWhen, applyWhenValue, createProperty, customError, disabled, email, emailError, form, hidden, listProperty, max, maxError, maxLength, maxLengthError, maxProperty, min, minError, minLength, minLengthError, minProperty, orProperty, pattern, patternError, property, readonly, reducedProperty, required, requiredError, schema, standardSchemaError, submit, validate, validateAsync, validateHttp, validateTree };
2382
- export type { AsyncValidationResult, AsyncValidatorOptions, ChildFieldContext, DisabledReason, Field, FieldContext, FieldPath, FieldState, FieldValidationResult, FieldValidator, FormCheckboxControl, FormOptions, FormUiControl, FormValueControl, HttpValidatorOptions, InteropSharedKeys, ItemFieldContext, LogicFn, MapToErrorsFn, MaybeField, MaybeFieldPath, Mutable, OneOrMany, ReadonlyArrayLike, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, Subfields, SubmittedStatus, TreeValidationResult, TreeValidator, ValidationError, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };
2612
+ export { AggregateProperty, Control, CustomValidationError, EmailValidationError, MAX, MAX_LENGTH, MIN, MIN_LENGTH, MaxLengthValidationError, MaxValidationError, MinLengthValidationError, MinValidationError, NgValidationError, PATTERN, PathKind, PatternValidationError, Property, REQUIRED, RequiredValidationError, StandardSchemaValidationError, aggregateProperty, andProperty, apply, applyEach, applyWhen, applyWhenValue, createProperty, customError, disabled, email, emailError, form, hidden, listProperty, max, maxError, maxLength, maxLengthError, maxProperty, min, minError, minLength, minLengthError, minProperty, orProperty, pattern, patternError, property, readonly, reducedProperty, required, requiredError, schema, standardSchemaError, submit, validate, validateAsync, validateHttp, validateStandardSchema, validateTree };
2613
+ export type { AsyncValidationResult, AsyncValidatorOptions, ChildFieldContext, DisabledReason, Field, FieldContext, FieldPath, FieldState, FieldValidationResult, FieldValidator, FormCheckboxControl, FormOptions, FormUiControl, FormValueControl, HttpValidatorOptions, IgnoreUnknownProperties, ItemFieldContext, LogicFn, MapToErrorsFn, MaybeField, MaybeFieldPath, Mutable, OneOrMany, ReadonlyArrayLike, RemoveStringIndexUnknownKey, RootFieldContext, Schema, SchemaFn, SchemaOrSchemaFn, Subfields, SubmittedStatus, TreeValidationResult, TreeValidator, ValidationError, ValidationResult, ValidationSuccess, Validator, WithField, WithOptionalField, WithoutField };