@orkestrel/form 0.0.4 → 0.0.6

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,14 +1,14 @@
1
- import { EmitterErrorHandler } from '@orkestrel/emitter';
2
- import { EmitterHooks } from '@orkestrel/emitter';
3
- import { EmitterInterface } from '@orkestrel/emitter';
4
- import { JSONRecord } from '@orkestrel/contract';
5
- import { Result } from '@orkestrel/contract';
1
+ import type { EmitterErrorHandler } from '@orkestrel/emitter';
2
+ import type { EmitterHooks } from '@orkestrel/emitter';
3
+ import type { EmitterInterface } from '@orkestrel/emitter';
4
+ import type { JSONRecord } from '@orkestrel/contract';
5
+ import type { Result } from '@orkestrel/contract';
6
6
 
7
- /** One or more ASCII letters or digits. */
7
+ /** Matches one or more ASCII letters or digits. */
8
8
  export declare const ALPHANUMERIC_PATTERN: Readonly<RegExp>;
9
9
 
10
10
  /**
11
- * Check whether a named rule applies to one field control.
11
+ * Checks whether a named rule applies to one field control.
12
12
  *
13
13
  * @remarks
14
14
  * The runtime control-membership check keeps this boundary total for JavaScript callers that
@@ -16,12 +16,12 @@ export declare const ALPHANUMERIC_PATTERN: Readonly<RegExp>;
16
16
  *
17
17
  * @param control - The field control to inspect.
18
18
  * @param rule - The named rule to inspect.
19
- * @returns Whether the control evaluates that rule.
19
+ * @returns True if the control evaluates that rule; false otherwise.
20
20
  */
21
21
  export declare function appliesRule(control: FieldControl, rule: FieldRuleName): boolean;
22
22
 
23
23
  /**
24
- * Audit a structurally valid schema for domain invariants.
24
+ * Audits a structurally valid schema for domain invariants.
25
25
  *
26
26
  * @param schema - The form schema to audit.
27
27
  * @returns Human-readable invariant violations, or an empty list when the schema is sound.
@@ -29,7 +29,7 @@ export declare function appliesRule(control: FieldControl, rule: FieldRuleName):
29
29
  export declare function auditSchema(schema: FormSchema): readonly string[];
30
30
 
31
31
  /**
32
- * Any number of choices out of a list, holding the checked values.
32
+ * Represents any number of choices out of a list, holding the checked values.
33
33
  *
34
34
  * @remarks
35
35
  * A field offering one box that means yes or no is a {@link ConfirmField}, not a one-choice
@@ -41,11 +41,11 @@ export declare interface CheckboxField extends FieldBase {
41
41
  readonly default?: readonly string[];
42
42
  }
43
43
 
44
- /** The maximum number of choices one `select` or `checkbox` field may offer. */
44
+ /** Caps the number of choices one `select` or `checkbox` field may offer, at 1024. */
45
45
  export declare const CHOICE_LIMIT = 1024;
46
46
 
47
47
  /**
48
- * Clone a field's choices into an owned frozen snapshot.
48
+ * Clones a field's choices into an owned frozen snapshot.
49
49
  *
50
50
  * @param choices - The choices to own.
51
51
  * @returns A frozen list of frozen choice records.
@@ -53,7 +53,7 @@ export declare const CHOICE_LIMIT = 1024;
53
53
  export declare function cloneChoices(choices: readonly FieldChoice[]): readonly FieldChoice[];
54
54
 
55
55
  /**
56
- * Clone one form field into an owned frozen snapshot.
56
+ * Clones one form field into an owned frozen snapshot.
57
57
  *
58
58
  * @param field - The field to own.
59
59
  * @returns A frozen field with every nested collection owned.
@@ -62,7 +62,7 @@ export declare function cloneChoices(choices: readonly FieldChoice[]): readonly
62
62
  export declare function cloneFormField(field: FormField): FormField;
63
63
 
64
64
  /**
65
- * Clone a form schema into an owned frozen snapshot.
65
+ * Clones a form schema into an owned frozen snapshot.
66
66
  *
67
67
  * @param schema - The schema to own.
68
68
  * @returns A frozen schema with every nested record and list owned.
@@ -70,7 +70,7 @@ export declare function cloneFormField(field: FormField): FormField;
70
70
  export declare function cloneFormSchema(schema: FormSchema): FormSchema;
71
71
 
72
72
  /**
73
- * Clone one form value into an owned frozen snapshot.
73
+ * Clones one form value into an owned frozen snapshot.
74
74
  *
75
75
  * @param value - The field value to own.
76
76
  * @returns The scalar unchanged, or a frozen copy of the list.
@@ -79,31 +79,57 @@ export declare function cloneValue(value: readonly string[]): readonly string[];
79
79
 
80
80
  export declare function cloneValue(value: FieldValue): FieldValue;
81
81
 
82
- /** A six-digit hexadecimal color string. */
82
+ /** Matches a six-digit hexadecimal color string. */
83
83
  export declare const COLOR_PATTERN: Readonly<RegExp>;
84
84
 
85
- /** A color, held as the control's own string. */
85
+ /** Represents a color, held as the control's own six-digit `#rrggbb` string. */
86
86
  export declare interface ColorField extends FieldBase {
87
87
  readonly control: 'color';
88
88
  readonly default?: string;
89
89
  }
90
90
 
91
91
  /**
92
- * Compute the values explicitly seeded by a schema.
92
+ * Computes the values explicitly seeded by a schema.
93
+ *
94
+ * @remarks
95
+ * `password` and `file` declare no default, so a field of either control never appears in the
96
+ * result.
93
97
  *
94
98
  * @param schema - The schema whose defaults to collect.
95
99
  * @returns A value record containing only fields with defaults.
96
100
  */
97
101
  export declare function computeDefaults(schema: FormSchema): FormValues;
98
102
 
99
- /** A single on/off box, holding a boolean. */
103
+ /** Represents a single on/off box, holding a boolean. */
100
104
  export declare interface ConfirmField extends FieldBase {
101
105
  readonly control: 'confirm';
102
106
  readonly default?: boolean;
103
107
  }
104
108
 
105
109
  /**
106
- * Open a form against a schema.
110
+ * Creates one named-rule failure against a field.
111
+ *
112
+ * @param field - The field the rule failed on.
113
+ * @param rule - The named rule that failed.
114
+ * @param limit - The rule's operand, substituted for `{limit}`, or absence when it carries none.
115
+ * @param messages - Optional rule-specific message replacements.
116
+ * @returns A frozen {@link FieldError} carrying the field's name, the resolved text, and the rule.
117
+ *
118
+ * @remarks
119
+ * A `custom` validator and the form's `invalidate` method both report a message of their own
120
+ * under no rule name, so neither builds its failure here.
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * const field: FormField = { control: 'text', name: 'nickname', rule: { minimum: 3 } }
125
+ * const error = createFieldError(field, 'minimum', 3)
126
+ * error.message // 'Must be at least 3'
127
+ * ```
128
+ */
129
+ export declare function createFieldError(field: FormField, rule: FieldRuleName, limit: number | string | undefined, messages?: Readonly<Partial<Record<FieldRuleName, string>>>): FieldError;
130
+
131
+ /**
132
+ * Opens a form against a schema.
107
133
  *
108
134
  * @param schema - The form to ask. It is copied, and the copy is what the form asks.
109
135
  * @param options - The form's settings.
@@ -114,8 +140,10 @@ export declare interface ConfirmField extends FieldBase {
114
140
  * @throws A {@link FormError} coded `SCHEMA` when the schema is malformed, `FIELD` when
115
141
  * `options.values` names a field the schema does not declare, and `CONTROL` when a seeded value
116
142
  * is one its field's control cannot hold.
117
- * @example
143
+ * @example Open a form, answer it, and settle it
118
144
  * ```ts
145
+ * import { createForm } from '@orkestrel/form'
146
+ *
119
147
  * const form = createForm({
120
148
  * label: 'Sign up',
121
149
  * fields: [
@@ -125,64 +153,89 @@ export declare interface ConfirmField extends FieldBase {
125
153
  * })
126
154
  *
127
155
  * form.fill({ email: 'ada@example.com', terms: true })
128
- * form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
156
+ * const result = form.submit() // { success: true, value: { email: 'ada@example.com', terms: true } }
157
+ * const answers = await form.answer // { email: 'ada@example.com', terms: true }
129
158
  * ```
130
159
  */
131
160
  export declare function createForm(schema: FormSchema, options?: FormOptions): FormInterface;
132
161
 
133
- /** An ISO calendar date string in `YYYY-MM-DD` form. */
162
+ /** Matches an ISO calendar date string in `YYYY-MM-DD` form. */
134
163
  export declare const DATE_PATTERN: Readonly<RegExp>;
135
164
 
136
- /** A calendar date, held as the control's own string. */
165
+ /** Represents a calendar date, held as the control's own `YYYY-MM-DD` string. */
137
166
  export declare interface DateField extends FieldBase {
138
167
  readonly control: 'date';
139
168
  readonly default?: string;
140
169
  }
141
170
 
142
- /** An ISO local date and time string with optional seconds. */
171
+ /** Matches an ISO local date and time string with optional seconds. */
143
172
  export declare const DATETIME_PATTERN: Readonly<RegExp>;
144
173
 
145
- /** A date and a time of day together, with no zone, held as the control's own string. */
174
+ /** Represents a date and a time of day together, with no zone, held as the control's own string. */
146
175
  export declare interface DatetimeField extends FieldBase {
147
176
  readonly control: 'datetime';
148
177
  readonly default?: string;
149
178
  }
150
179
 
151
- /** Text over many lines. */
180
+ /**
181
+ * Writes one own enumerable data property onto a record.
182
+ *
183
+ * @param target - The record to write into.
184
+ * @param name - The property name to write.
185
+ * @param value - The value to store.
186
+ *
187
+ * @remarks
188
+ * Plain assignment runs an inherited setter, so writing a `__proto__` key that way reaches
189
+ * `Object.prototype` and leaves the record without the entry. Defining the property writes the
190
+ * record itself, whatever the prototype chain declares. The entry stays writable and configurable.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * const values: Record<string, number> = {}
195
+ * defineEntry(values, '__proto__', 1)
196
+ * Object.hasOwn(values, '__proto__') // true
197
+ * ```
198
+ */
199
+ export declare function defineEntry<T>(target: Record<string, T>, name: string, value: T): void;
200
+
201
+ /** Represents text over many lines. */
152
202
  export declare interface EditorField extends FieldBase {
153
203
  readonly control: 'editor';
154
204
  readonly default?: string;
155
205
  readonly placeholder?: string;
156
206
  }
157
207
 
158
- /** A practical whole-address email shape. */
208
+ /** Matches a practical whole-address email shape. */
159
209
  export declare const EMAIL_PATTERN: Readonly<RegExp>;
160
210
 
161
211
  /**
162
- * Evaluate one field rule against its current value.
212
+ * Evaluates one field rule against its current value.
163
213
  *
164
214
  * @param field - The field and rule to evaluate.
165
215
  * @param value - The current value, or absence.
166
216
  * @param values - Every value available to a custom rule.
167
217
  * @param messages - Optional rule-specific message replacements.
168
218
  * @returns Every failure in rule order.
219
+ * @throws Thrown when a {@link FieldValidator} supplied through {@link FieldRule.custom} throws:
220
+ * its own value escapes unchanged, because this helper adds no boundary around it.
169
221
  */
170
222
  export declare function evaluateField(field: FormField, value: FieldValue | undefined, values: FormValues, messages?: Readonly<Partial<Record<FieldRuleName, string>>>): readonly FieldError[];
171
223
 
172
224
  /**
173
- * Evaluate every active field in schema order.
225
+ * Evaluates every active field in schema order.
174
226
  *
175
227
  * @param schema - The form schema to evaluate.
176
228
  * @param values - The values keyed by field name.
177
229
  * @param options - Optional message replacements and the effective disabled field set.
178
230
  * @returns Every field failure in schema and rule order.
231
+ * @throws Thrown when a {@link FieldValidator} supplied through {@link FieldRule.custom} throws:
232
+ * its own value escapes unchanged, because this helper adds no boundary around it.
179
233
  */
180
234
  export declare function evaluateForm(schema: FormSchema, values: FormValues, options?: EvaluationOptions): readonly FieldError[];
181
235
 
182
236
  /**
183
- * How to check a schema against a set of answers.
237
+ * Describes how to check a schema against a set of answers.
184
238
  *
185
- * @param options - The evaluation's settings.
186
239
  * @remarks
187
240
  * `messages` replaces the default message of a rule, keyed by {@link FieldRuleName}.
188
241
  *
@@ -205,40 +258,49 @@ export declare interface EvaluationOptions {
205
258
  }
206
259
 
207
260
  /**
208
- * Extract the names whose answers differ between two form value records.
261
+ * Extracts the names whose answers differ between two form value records.
209
262
  *
210
263
  * @remarks
211
264
  * Presence is compared in both directions before present values are compared through
212
265
  * {@link matchesValue}. The returned set is a new snapshot, exposed as readonly because later
213
266
  * changes to either input never alter its membership.
214
267
  *
215
- * @param current - The values held now.
268
+ * @param current - The values the form holds.
216
269
  * @param opened - The values held when the form opened.
217
270
  * @returns A readonly snapshot of changed field names.
218
271
  */
219
272
  export declare function extractChanges(current: FormValues, opened: FormValues): ReadonlySet<string>;
220
273
 
221
274
  /**
222
- * Select referenced groups in first-reference field order.
275
+ * Selects referenced groups in first-reference field order.
223
276
  *
224
277
  * @param schema - The schema whose group references to resolve.
225
278
  * @returns The referenced schema groups without duplicates.
226
279
  */
227
280
  export declare function extractGroups(schema: FormSchema): readonly FormGroup[];
228
281
 
229
- /** Every field control, in the order declared by the public contract. */
282
+ /** Lists the members every field declares, whatever its control. */
283
+ export declare const FIELD_BASE_KEYS: readonly string[];
284
+
285
+ /** Lists every field control, in the order declared by the public contract. */
230
286
  export declare const FIELD_CONTROLS: readonly FieldControl[];
231
287
 
232
- /** The maximum number of fields one schema may declare. */
288
+ /**
289
+ * Lists every member one field control permits, composed from {@link FIELD_BASE_KEYS} and the
290
+ * members the control's own interface adds.
291
+ */
292
+ export declare const FIELD_KEYS: Readonly<Record<FieldControl, readonly string[]>>;
293
+
294
+ /** Caps the number of fields one schema may declare, at 512. */
233
295
  export declare const FIELD_LIMIT = 512;
234
296
 
235
297
  /**
236
- * What every field carries, whatever its control.
298
+ * Declares what every field carries, whatever its control.
237
299
  *
238
300
  * @remarks
239
301
  * `name` keys the field in {@link FormValues} and `group` names a {@link FormGroup}.
240
302
  *
241
- * The three visibility switches differ in what they remove. `hidden` keeps the field out of
303
+ * `hidden`, `locked`, and `disabled` differ in what they remove. `hidden` keeps the field out of
242
304
  * the rendered form, `locked` renders it unwritable, and both are still validated and still
243
305
  * submitted. `disabled` takes the field out of the form entirely: it is neither validated nor
244
306
  * submitted. It is the field's declared, opening state; {@link FormInterface.disabled} is the
@@ -261,7 +323,7 @@ export declare interface FieldBase {
261
323
  }
262
324
 
263
325
  /**
264
- * One option a `select` or `checkbox` field offers.
326
+ * Represents one option a `select` or `checkbox` field offers.
265
327
  *
266
328
  * @remarks
267
329
  * `value` is what the form stores and `label` is what the person reads. `help` explains the
@@ -276,16 +338,16 @@ export declare interface FieldChoice {
276
338
  }
277
339
 
278
340
  /**
279
- * The control a field presents to the person answering it.
341
+ * Names the control a field presents to the person answering it.
280
342
  *
281
343
  * @remarks
282
344
  * The control is the discriminant of every {@link FormField} variant, so choosing it fixes
283
345
  * which options that field accepts and which {@link FieldValue} it holds.
284
346
  *
285
- * Three members need saying out loud. `confirm` is a single on/off box holding a boolean, so
286
- * a lone browser checkbox is a `confirm`. `checkbox` is the multi-choice group holding the
287
- * checked values as a list, never a single box. `datetime` is the browser's `datetime-local`:
288
- * a wall-clock date and time carrying no zone.
347
+ * The `confirm`, `checkbox`, and `datetime` members need saying out loud. `confirm` is a single
348
+ * on/off box holding a boolean, so a lone browser checkbox is a `confirm`. `checkbox` is the
349
+ * multi-choice group holding the checked values as a list, never a single box. `datetime` is the
350
+ * browser's `datetime-local`: a wall-clock date and time carrying no zone.
289
351
  *
290
352
  * @example
291
353
  * ```ts
@@ -295,7 +357,7 @@ export declare interface FieldChoice {
295
357
  export declare type FieldControl = 'text' | 'editor' | 'password' | 'number' | 'date' | 'time' | 'datetime' | 'color' | 'confirm' | 'select' | 'checkbox' | 'file';
296
358
 
297
359
  /**
298
- * One failed check against one field.
360
+ * Represents one failed check against one field.
299
361
  *
300
362
  * @remarks
301
363
  * `rule` names the constraint that failed. It is absent when the message came from a
@@ -309,7 +371,7 @@ export declare interface FieldError {
309
371
  }
310
372
 
311
373
  /**
312
- * The constraints one field's value must satisfy.
374
+ * Represents the constraints one field's value must satisfy.
313
375
  *
314
376
  * @remarks
315
377
  * `minimum` and `maximum` measure whatever the control makes countable: characters for
@@ -340,7 +402,7 @@ export declare interface FieldRule {
340
402
  }
341
403
 
342
404
  /**
343
- * Every rule that reports its failure by name.
405
+ * Lists every rule that reports its failure by name.
344
406
  *
345
407
  * @remarks
346
408
  * `custom` is excluded because it supplies its own message, so nothing keyed by a rule name
@@ -349,20 +411,21 @@ export declare interface FieldRule {
349
411
  export declare type FieldRuleName = Exclude<keyof FieldRule, 'custom'>;
350
412
 
351
413
  /**
352
- * Check one value against the whole form.
414
+ * Checks one value against the whole form.
353
415
  *
354
416
  * @remarks
355
417
  * It runs after every named rule, and it runs on an absent value as well as a present one. That
356
418
  * is what makes a rule such as "required once the sibling says yes" expressible, and it means an
357
419
  * unanswered field can carry both a `required` message and this validator's own.
358
420
  *
359
- * @param value - The value the field currently holds, or `undefined` when nobody has answered it.
421
+ * @param value - The value the field holds, or `undefined` when nobody has answered it.
360
422
  * @param values - Every answer the form holds, so a rule can read its siblings.
361
423
  * @returns `true` when the value passes, or the message explaining why it failed.
362
- * @throws The validator's own thrown value escapes the mutation call unchanged. When a form
363
- * mutation has already changed state, the throw leaves those changes beside the error list
364
- * from before that mutation. An invalidation can therefore be recorded without appearing in
365
- * `errors`, and a clear can reset state without emitting `clear`. Form-owned refusals use
424
+ * @throws Thrown when a {@link FieldValidator} throws; its own thrown value escapes the mutation
425
+ * call unchanged. When a form mutation has already changed state, the throw leaves those
426
+ * changes beside the error list from before that mutation. An invalidation can therefore be
427
+ * recorded without appearing in `errors`, and a clear can reset state without emitting `clear`.
428
+ * Form-owned refusals use
366
429
  * {@link FormError} instead.
367
430
  * @example
368
431
  * ```ts
@@ -373,7 +436,7 @@ export declare type FieldRuleName = Exclude<keyof FieldRule, 'custom'>;
373
436
  export declare type FieldValidator = (value: FieldValue | undefined, values: FormValues) => true | string;
374
437
 
375
438
  /**
376
- * Every value a field can hold.
439
+ * Represents every value a field can hold.
377
440
  *
378
441
  * @remarks
379
442
  * The variant follows the control: text-like controls hold a `string`, `number` holds a
@@ -383,11 +446,11 @@ export declare type FieldValidator = (value: FieldValue | undefined, values: For
383
446
  export declare type FieldValue = string | number | boolean | readonly string[];
384
447
 
385
448
  /**
386
- * One or more files.
449
+ * Represents one or more files, by name.
387
450
  *
388
451
  * @remarks
389
- * `accept` lists the media types and extensions the control offers, in the form the host
390
- * expects.
452
+ * A value is the names alone: bytes never enter the document. `accept` lists the media types
453
+ * and extensions the control offers, in the form the host expects.
391
454
  */
392
455
  export declare interface FileField extends FieldBase {
393
456
  readonly control: 'file';
@@ -396,7 +459,8 @@ export declare interface FileField extends FieldBase {
396
459
  }
397
460
 
398
461
  /**
399
- * A form: a schema, the answers given against it, and the errors they carry.
462
+ * Implements `FormInterface` exactly, over an owned schema, the answers given against it, and the
463
+ * errors they carry.
400
464
  *
401
465
  * @remarks
402
466
  * The form owns its schema, so a later edit to the schema the caller passed changes nothing here.
@@ -423,7 +487,7 @@ export declare interface FileField extends FieldBase {
423
487
  export declare class Form implements FormInterface {
424
488
  #private;
425
489
  /**
426
- * Open a form against a schema.
490
+ * Opens a form against a schema.
427
491
  *
428
492
  * @param schema - The form to ask. It is copied, and the copy is what the form asks.
429
493
  * @param options - The form's settings.
@@ -432,28 +496,28 @@ export declare class Form implements FormInterface {
432
496
  * value is one its field's control cannot hold.
433
497
  */
434
498
  constructor(schema: FormSchema, options?: FormOptions);
435
- /** The form's event emitter. */
499
+ /** Holds the form's event emitter. */
436
500
  get emitter(): EmitterInterface<FormEventMap>;
437
- /** The schema this form asks, owned and frozen. */
501
+ /** Holds the schema this form asks, owned and frozen. */
438
502
  get schema(): FormSchema;
439
- /** The answers held right now. */
503
+ /** Reports the answers the form holds. */
440
504
  get values(): FormValues;
441
- /** The answers the form opened with. */
505
+ /** Holds the answers the form opened with. */
442
506
  get baseline(): FormValues;
443
- /** Every error the last completed evaluation produced. */
507
+ /** Holds every error the last completed evaluation produced. */
444
508
  get errors(): readonly FieldError[];
445
- /** The names of the fields somebody has visited. */
509
+ /** Lists the names of the fields somebody has visited. */
446
510
  get touched(): ReadonlySet<string>;
447
- /** The names of the fields currently out of the form. */
511
+ /** Lists the names of the fields that are out of the form. */
448
512
  get disabled(): ReadonlySet<string>;
449
- /** Where the form sits in its life. */
513
+ /** Reports where the form sits in its life. */
450
514
  get status(): FormStatus;
451
- /** Whether the last completed evaluation found no error. */
515
+ /** Reports whether the last completed evaluation found no error. */
452
516
  get valid(): boolean;
453
- /** Whether any answer has moved since the form opened. */
517
+ /** Reports whether any answer has moved since the form opened. */
454
518
  get dirty(): boolean;
455
519
  /**
456
- * The answers, once the form settles.
520
+ * Holds the answers after the form settles.
457
521
  *
458
522
  * @remarks
459
523
  * It resolves with the submitted values on the first valid submit, and rejects with a
@@ -461,27 +525,27 @@ export declare class Form implements FormInterface {
461
525
  */
462
526
  get answer(): Promise<FormValues>;
463
527
  /**
464
- * Find one field by name.
528
+ * Finds one field by name.
465
529
  *
466
530
  * @param name - The field's name.
467
531
  * @returns The field, or `undefined` when the schema declares no such name.
468
532
  */
469
533
  field(name: string): FormField | undefined;
470
534
  /**
471
- * Answer several fields at once.
535
+ * Answers several fields at once.
472
536
  *
473
537
  * @param values - The answers to write, each keyed by its field name.
474
538
  */
475
539
  fill(values: FormValues): void;
476
540
  /**
477
- * Answer one field.
541
+ * Answers one field.
478
542
  *
479
543
  * @param name - The field's name.
480
544
  * @param value - The answer to write, or `undefined` to clear it.
481
545
  */
482
546
  fill(name: string, value: FieldValue | undefined): void;
483
547
  /**
484
- * Record that somebody has visited a field.
548
+ * Records that somebody has visited a field.
485
549
  *
486
550
  * @param name - The field's name.
487
551
  * @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended, and
@@ -489,7 +553,7 @@ export declare class Form implements FormInterface {
489
553
  */
490
554
  touch(name: string): void;
491
555
  /**
492
- * Fail a field from outside, for what the rules cannot see.
556
+ * Fails a field from outside, for what the rules cannot see.
493
557
  *
494
558
  * @param name - The field's name.
495
559
  * @param message - What to tell the person.
@@ -500,36 +564,36 @@ export declare class Form implements FormInterface {
500
564
  * `FIELD` when the schema declares no such name.
501
565
  */
502
566
  invalidate(name: string, message: string): void;
503
- /** Take every field out of the form. */
567
+ /** Takes every field out of the form. */
504
568
  disable(): void;
505
569
  /**
506
- * Take one field out of the form.
570
+ * Takes one field out of the form.
507
571
  *
508
572
  * @param name - The field's name.
509
573
  */
510
574
  disable(name: string): void;
511
575
  /**
512
- * Take several fields out of the form.
576
+ * Takes several fields out of the form.
513
577
  *
514
578
  * @param names - The field names.
515
579
  */
516
580
  disable(names: readonly string[]): void;
517
- /** Put every field back into the form. */
581
+ /** Puts every field back into the form. */
518
582
  enable(): void;
519
583
  /**
520
- * Put one field back into the form.
584
+ * Puts one field back into the form.
521
585
  *
522
586
  * @param name - The field's name.
523
587
  */
524
588
  enable(name: string): void;
525
589
  /**
526
- * Put several fields back into the form.
590
+ * Puts several fields back into the form.
527
591
  *
528
592
  * @param names - The field names.
529
593
  */
530
594
  enable(names: readonly string[]): void;
531
595
  /**
532
- * Check every answer and settle the form when they all pass.
596
+ * Checks every answer and settles the form when they all pass.
533
597
  *
534
598
  * @returns The values on success, or every error that stopped them.
535
599
  * @remarks
@@ -546,14 +610,14 @@ export declare class Form implements FormInterface {
546
610
  */
547
611
  submit(): FormResult;
548
612
  /**
549
- * Return every answer to the ones the form opened with: the schema's defaults, overlaid with
613
+ * Returns every answer to the ones the form opened with: the schema's defaults, overlaid with
550
614
  * any seeded `values`. Reset the runtime disabled state to the schema's declarations.
551
615
  *
552
616
  * @throws A {@link FormError} coded `SETTLED` or `ABANDONED` when the form has ended.
553
617
  */
554
618
  clear(): void;
555
619
  /**
556
- * Tear the form down, abandoning it when it has not settled.
620
+ * Tears the form down, abandoning it when it has not settled.
557
621
  *
558
622
  * @remarks
559
623
  * Destroying twice does nothing the second time. A settled form keeps its `settled` status and
@@ -564,11 +628,15 @@ export declare class Form implements FormInterface {
564
628
  destroy(): void;
565
629
  }
566
630
 
567
- /** Every form lifecycle status. */
631
+ /** Lists every form lifecycle status. */
568
632
  export declare const FORM_STATUSES: readonly FormStatus[];
569
633
 
570
634
  /**
571
- * Resolve and interpolate one rule message.
635
+ * Resolves and interpolates one rule message.
636
+ *
637
+ * @remarks
638
+ * A replacement in `messages` is read first and {@link RULE_MESSAGES} supplies the copy otherwise,
639
+ * and `{limit}` in whichever text wins is replaced with the rule's operand.
572
640
  *
573
641
  * @param rule - The rule whose message to resolve.
574
642
  * @param limit - The optional operand substituted for `{limit}`.
@@ -577,14 +645,26 @@ export declare const FORM_STATUSES: readonly FormStatus[];
577
645
  */
578
646
  export declare function formatMessage(rule: FieldRuleName, limit?: number | string, messages?: Readonly<Partial<Record<FieldRuleName, string>>>): string;
579
647
 
580
- /** An error raised by the form domain. */
648
+ /**
649
+ * Represents an error raised by the form domain.
650
+ *
651
+ * @example
652
+ * ```ts
653
+ * const error = new FormError('FIELD', 'The schema declares no field named "nickname"', {
654
+ * field: 'nickname',
655
+ * })
656
+ *
657
+ * error.code // 'FIELD'
658
+ * error.context // { field: 'nickname' }
659
+ * ```
660
+ */
581
661
  export declare class FormError extends Error {
582
- /** The machine-readable reason for this failure. */
662
+ /** Holds the machine-readable reason for this failure. */
583
663
  readonly code: FormErrorCode;
584
- /** Structured values that locate or explain this failure. */
664
+ /** Holds structured values that locate or explain this failure. */
585
665
  readonly context?: JSONRecord;
586
666
  /**
587
- * Create a form error.
667
+ * Creates a form error.
588
668
  *
589
669
  * @param code - The machine-readable reason.
590
670
  * @param message - The human-readable failure text.
@@ -594,7 +674,7 @@ export declare class FormError extends Error {
594
674
  }
595
675
 
596
676
  /**
597
- * The machine-readable code a form error carries.
677
+ * Names the machine-readable code a form error carries.
598
678
  *
599
679
  * @remarks
600
680
  * `SCHEMA` rejects a malformed schema. `FIELD` names a field the schema does not declare.
@@ -604,7 +684,7 @@ export declare class FormError extends Error {
604
684
  export declare type FormErrorCode = 'SCHEMA' | 'FIELD' | 'CONTROL' | 'SETTLED' | 'ABANDONED';
605
685
 
606
686
  /**
607
- * Everything a form announces.
687
+ * Lists everything a form announces.
608
688
  *
609
689
  * @remarks
610
690
  * `fill` carries the field that changed and its new value, where `undefined` is the value
@@ -624,7 +704,7 @@ export declare type FormEventMap = {
624
704
  };
625
705
 
626
706
  /**
627
- * Any field a schema can declare.
707
+ * Represents any field a schema can declare.
628
708
  *
629
709
  * @remarks
630
710
  * The union discriminates on `control`, so narrowing on that member reaches each variant's
@@ -640,7 +720,7 @@ export declare type FormEventMap = {
640
720
  export declare type FormField = TextField | EditorField | PasswordField | NumberField | DateField | TimeField | DatetimeField | ColorField | ConfirmField | SelectField | CheckboxField | FileField;
641
721
 
642
722
  /**
643
- * A named section of a form.
723
+ * Represents a named section of a form.
644
724
  *
645
725
  * @remarks
646
726
  * A field joins a group through {@link FieldBase.group}. Grouping arranges the form and
@@ -653,7 +733,7 @@ export declare interface FormGroup {
653
733
  }
654
734
 
655
735
  /**
656
- * A form: a schema, the answers given against it, and the errors they carry.
736
+ * Declares the contract a form exposes: the state it holds and the calls that move it.
657
737
  *
658
738
  * @remarks
659
739
  * `valid` is true when the last completed evaluation found no error, and `dirty` is true once
@@ -670,26 +750,26 @@ export declare interface FormGroup {
670
750
  * ```
671
751
  */
672
752
  export declare interface FormInterface {
673
- /** The form's event emitter. */
753
+ /** Holds the form's event emitter. */
674
754
  readonly emitter: EmitterInterface<FormEventMap>;
675
- /** The schema this form asks. */
755
+ /** Holds the schema this form asks. */
676
756
  readonly schema: FormSchema;
677
- /** The answers held right now. */
757
+ /** Reports the answers the form holds. */
678
758
  readonly values: FormValues;
679
759
  /**
680
- * The answers the form opened with: the schema's defaults, overlaid with any seeded values.
760
+ * Holds the answers the form opened with: the schema's defaults, overlaid with any seeded values.
681
761
  *
682
762
  * @remarks
683
763
  * It is fixed when the form opens and never moves again, so it is what `dirty` measures
684
764
  * against and what {@link FormInterface.clear} returns to.
685
765
  */
686
766
  readonly baseline: FormValues;
687
- /** Every error the last check produced. */
767
+ /** Holds every error the last check produced. */
688
768
  readonly errors: readonly FieldError[];
689
- /** The names of the fields somebody has visited. */
769
+ /** Lists the names of the fields somebody has visited. */
690
770
  readonly touched: ReadonlySet<string>;
691
771
  /**
692
- * The names of the fields currently out of the form.
772
+ * Lists the names of the fields that are out of the form.
693
773
  *
694
774
  * @remarks
695
775
  * It opens as the set the schema declares through {@link FieldBase.disabled} and moves with
@@ -697,14 +777,14 @@ export declare interface FormInterface {
697
777
  * holds the declaration and this holds the current fact.
698
778
  */
699
779
  readonly disabled: ReadonlySet<string>;
700
- /** Where the form sits in its life. */
780
+ /** Reports where the form sits in its life. */
701
781
  readonly status: FormStatus;
702
- /** Whether the last completed evaluation found no error. */
782
+ /** Reports whether the last completed evaluation found no error. */
703
783
  readonly valid: boolean;
704
- /** Whether any answer has moved since the form opened. */
784
+ /** Reports whether any answer has moved since the form opened. */
705
785
  readonly dirty: boolean;
706
786
  /**
707
- * The answers, once the form settles.
787
+ * Holds the answers after the form settles.
708
788
  *
709
789
  * @remarks
710
790
  * It resolves with the submitted values on the first valid submit, and rejects when teardown
@@ -712,40 +792,44 @@ export declare interface FormInterface {
712
792
  */
713
793
  readonly answer: Promise<FormValues>;
714
794
  /**
715
- * Find one field by name.
795
+ * Finds one field by name.
716
796
  *
717
797
  * @param name - The field's name.
718
798
  * @returns The field, or `undefined` when the schema declares no such name.
719
799
  */
720
800
  field(name: string): FormField | undefined;
721
801
  /**
722
- * Answer several fields at once.
802
+ * Answers one field, or several at once.
723
803
  *
724
804
  * @param values - The answers to write, each keyed by its field name.
725
805
  */
726
806
  fill(values: FormValues): void;
727
807
  /**
728
- * Answer one field.
808
+ * Answers one field.
729
809
  *
730
810
  * @param name - The field's name.
731
811
  * @param value - The answer to write, or `undefined` to clear it.
732
812
  */
733
813
  fill(name: string, value: FieldValue | undefined): void;
734
814
  /**
735
- * Record that somebody has visited a field.
815
+ * Records that somebody has visited a field.
736
816
  *
737
817
  * @param name - The field's name.
738
818
  */
739
819
  touch(name: string): void;
740
820
  /**
741
- * Fail a field from outside, for what the rules cannot see.
821
+ * Fails a field from outside, for what the rules cannot see.
822
+ *
823
+ * @remarks
824
+ * One field holds one external failure, so a second call replaces the first, and the failure
825
+ * lasts until that field is filled again or the form is cleared.
742
826
  *
743
827
  * @param name - The field's name.
744
828
  * @param message - What to tell the person.
745
829
  */
746
830
  invalidate(name: string, message: string): void;
747
831
  /**
748
- * Take every field out of the form.
832
+ * Takes one field, several fields, or every field out of the form.
749
833
  *
750
834
  * @remarks
751
835
  * A disabled field is neither evaluated nor submitted. Its answer is kept, and so is any
@@ -756,14 +840,14 @@ export declare interface FormInterface {
756
840
  */
757
841
  disable(): void;
758
842
  /**
759
- * Take one field out of the form.
843
+ * Takes one field out of the form.
760
844
  *
761
845
  * @param name - The field's name.
762
846
  * @throws A {@link FormError} coded `FIELD` when the schema declares no such name.
763
847
  */
764
848
  disable(name: string): void;
765
849
  /**
766
- * Take several fields out of the form.
850
+ * Takes several fields out of the form.
767
851
  *
768
852
  * @param names - The field names.
769
853
  * @throws A {@link FormError} coded `FIELD` when the schema declares no such name. Every name
@@ -771,7 +855,7 @@ export declare interface FormInterface {
771
855
  */
772
856
  disable(names: readonly string[]): void;
773
857
  /**
774
- * Put every field back into the form.
858
+ * Puts one field, several fields, or every field back into the form.
775
859
  *
776
860
  * @remarks
777
861
  * An enabled field is evaluated and submitted again, and any invalidation held while it was
@@ -780,14 +864,14 @@ export declare interface FormInterface {
780
864
  */
781
865
  enable(): void;
782
866
  /**
783
- * Put one field back into the form.
867
+ * Puts one field back into the form.
784
868
  *
785
869
  * @param name - The field's name.
786
870
  * @throws A {@link FormError} coded `FIELD` when the schema declares no such name.
787
871
  */
788
872
  enable(name: string): void;
789
873
  /**
790
- * Put several fields back into the form.
874
+ * Puts several fields back into the form.
791
875
  *
792
876
  * @param names - The field names.
793
877
  * @throws A {@link FormError} coded `FIELD` when the schema declares no such name. Every name
@@ -795,33 +879,33 @@ export declare interface FormInterface {
795
879
  */
796
880
  enable(names: readonly string[]): void;
797
881
  /**
798
- * Check every answer and settle the form when they all pass.
882
+ * Checks every answer and settles the form when they all pass.
799
883
  *
800
884
  * @returns The values on success, or every error that stopped them.
801
885
  */
802
886
  submit(): FormResult;
803
887
  /**
804
- * Return every answer to {@link FormInterface.baseline}, the answers the form opened with.
888
+ * Returns every answer to the ones the form opened with.
805
889
  *
806
890
  * @remarks
807
- * The runtime disabled overlay resets with them, so {@link FormInterface.disabled} reads the
808
- * schema's declarations again.
891
+ * Those answers are {@link FormInterface.baseline}. The runtime disabled overlay resets with
892
+ * them, so {@link FormInterface.disabled} reads the schema's declarations again.
809
893
  */
810
894
  clear(): void;
811
895
  /**
812
- * Tear the form down, abandoning it when it has not settled.
896
+ * Tears the form down, abandoning it when it has not settled.
813
897
  *
814
898
  * @remarks
815
- * A request from inside a listener defers teardown until the outermost mutation batch closes,
816
- * so an in-flight settlement can win and leave the form `settled` rather than `abandoned`.
899
+ * Tearing down twice does nothing the second time. A request from inside a listener defers
900
+ * teardown until the outermost mutation batch closes, so an in-flight settlement can win and
901
+ * leave the form `settled` rather than `abandoned`.
817
902
  */
818
903
  destroy(): void;
819
904
  }
820
905
 
821
906
  /**
822
- * How to open a form.
907
+ * Describes how to open a form.
823
908
  *
824
- * @param options - The form's settings.
825
909
  * @remarks
826
910
  * `on` wires listeners at construction and `error` receives any throw from one of them.
827
911
  * `values` seeds the answers, overriding each field's declared default. `messages` replaces
@@ -844,7 +928,7 @@ export declare interface FormOptions {
844
928
  }
845
929
 
846
930
  /**
847
- * What a submit answers with: the values, or every error that stopped them.
931
+ * Reports what a submit answers with: the values, or every error that stopped them.
848
932
  *
849
933
  * @example
850
934
  * ```ts
@@ -855,7 +939,7 @@ export declare interface FormOptions {
855
939
  export declare type FormResult = Result<FormValues, readonly FieldError[]>;
856
940
 
857
941
  /**
858
- * Everything a form asks.
942
+ * Describes everything a form asks.
859
943
  *
860
944
  * @remarks
861
945
  * `fields` is the schema's only required member, and the order it declares is the order the
@@ -881,7 +965,7 @@ export declare interface FormSchema {
881
965
  }
882
966
 
883
967
  /**
884
- * Where a form sits in its life.
968
+ * Represents where a form sits in its life.
885
969
  *
886
970
  * @remarks
887
971
  * A form opens `editing`, turns `settled` on its first valid submit, and turns `abandoned`
@@ -895,7 +979,7 @@ export declare interface FormSchema {
895
979
  export declare type FormStatus = 'editing' | 'settled' | 'abandoned';
896
980
 
897
981
  /**
898
- * A form's answers, keyed by field name.
982
+ * Represents a form's answers, keyed by field name.
899
983
  *
900
984
  * @remarks
901
985
  * A name with no key is a field nobody has answered. A disabled field's value may appear so a
@@ -908,62 +992,86 @@ export declare type FormStatus = 'editing' | 'settled' | 'abandoned';
908
992
  */
909
993
  export declare type FormValues = Readonly<Record<string, FieldValue>>;
910
994
 
911
- /** The maximum number of groups one schema may declare. */
995
+ /**
996
+ * Writes one own enumerable data property that cannot be rewritten or removed.
997
+ *
998
+ * @param target - The record to write into.
999
+ * @param name - The property name to write.
1000
+ * @param value - The value to store.
1001
+ *
1002
+ * @remarks
1003
+ * The prototype-safe write of {@link defineEntry}, frozen: the entry is neither writable nor
1004
+ * configurable, so the record a parser hands back cannot be edited through the key it filled.
1005
+ *
1006
+ * @example
1007
+ * ```ts
1008
+ * const values: Record<string, number> = {}
1009
+ * freezeEntry(values, '__proto__', 1)
1010
+ * Object.getOwnPropertyDescriptor(values, '__proto__')?.writable // false
1011
+ * ```
1012
+ */
1013
+ export declare function freezeEntry<T>(target: Record<string, T>, name: string, value: T): void;
1014
+
1015
+ /** Caps the number of groups one schema may declare, at 64. */
912
1016
  export declare const GROUP_LIMIT = 64;
913
1017
 
914
- /** A signed or unsigned base-ten integer string. */
1018
+ /** Matches a signed or unsigned base-ten integer string. */
915
1019
  export declare const INTEGER_PATTERN: Readonly<RegExp>;
916
1020
 
917
1021
  /**
918
- * Determine whether an unknown value is one exact field choice record.
1022
+ * Determines whether an unknown value is one exact field choice record.
919
1023
  *
920
1024
  * @param input - The value to inspect.
921
- * @returns Whether the value is a field choice.
1025
+ * @returns True if the value is a field choice; false otherwise.
922
1026
  */
923
1027
  export declare function isFieldChoice(input: unknown): input is FieldChoice;
924
1028
 
925
1029
  /**
926
- * Determine whether an unknown value is a declared field control.
1030
+ * Determines whether an unknown value is a declared field control.
927
1031
  *
928
1032
  * @param input - The value to inspect.
929
- * @returns Whether the value is a field control.
1033
+ * @returns True if the value is a field control; false otherwise.
930
1034
  */
931
1035
  export declare function isFieldControl(input: unknown): input is FieldControl;
932
1036
 
933
1037
  /**
934
- * Determine whether an unknown value is one exact field error record.
1038
+ * Determines whether an unknown value is one exact field error record.
935
1039
  *
936
1040
  * @param input - The value to inspect.
937
- * @returns Whether the value is a field error.
1041
+ * @returns True if the value is a field error; false otherwise.
938
1042
  */
939
1043
  export declare function isFieldError(input: unknown): input is FieldError;
940
1044
 
941
1045
  /**
942
- * Determine whether an unknown value is one exact field rule record.
1046
+ * Determines whether an unknown value is one exact field rule record.
943
1047
  *
944
1048
  * @param input - The value to inspect.
945
- * @returns Whether the value is a structurally valid field rule.
1049
+ * @returns True if the value is a structurally valid field rule; false otherwise.
946
1050
  */
947
1051
  export declare function isFieldRule(input: unknown): input is FieldRule;
948
1052
 
949
1053
  /**
950
- * Determine whether an unknown value has a form field value shape.
1054
+ * Determines whether an unknown value has a form field value shape.
1055
+ *
1056
+ * @remarks
1057
+ * A string, a finite number, a boolean, and a list of strings each qualify. A number that is not
1058
+ * finite does not, so `NaN` and `Infinity` are refused.
951
1059
  *
952
1060
  * @param input - The value to inspect.
953
- * @returns Whether the value is a field value.
1061
+ * @returns True if the value is a field value; false otherwise.
954
1062
  */
955
1063
  export declare function isFieldValue(input: unknown): input is FieldValue;
956
1064
 
957
1065
  /**
958
- * Determine whether an unknown value is a form error.
1066
+ * Determines whether an unknown value is a form error.
959
1067
  *
960
1068
  * @param input - The value to inspect.
961
- * @returns Whether the value is a {@link FormError} instance.
1069
+ * @returns True if the value is a {@link FormError} instance; false otherwise.
962
1070
  */
963
1071
  export declare function isFormError(input: unknown): input is FormError;
964
1072
 
965
1073
  /**
966
- * Determine whether an unknown value is one exact discriminated form field.
1074
+ * Determines whether an unknown value is one exact discriminated form field.
967
1075
  *
968
1076
  * @remarks
969
1077
  * Metadata is admitted structurally as bounded JSON. An accessor-bearing metadata record is
@@ -971,47 +1079,51 @@ export declare function isFormError(input: unknown): input is FormError;
971
1079
  * data properties only.
972
1080
  *
973
1081
  * @param input - The value to inspect.
974
- * @returns Whether the value is a structurally valid form field.
1082
+ * @returns True if the value is a structurally valid form field; false otherwise.
975
1083
  */
976
1084
  export declare function isFormField(input: unknown): input is FormField;
977
1085
 
978
1086
  /**
979
- * Determine whether an unknown value is one exact form group record.
1087
+ * Determines whether an unknown value is one exact form group record.
980
1088
  *
981
1089
  * @param input - The value to inspect.
982
- * @returns Whether the value is a form group.
1090
+ * @returns True if the value is a form group; false otherwise.
983
1091
  */
984
1092
  export declare function isFormGroup(input: unknown): input is FormGroup;
985
1093
 
986
1094
  /**
987
- * Determine whether an unknown value is one exact structural form schema.
1095
+ * Determines whether an unknown value is one exact structural form schema.
1096
+ *
1097
+ * @remarks
1098
+ * Structure alone is read. Domain soundness — a duplicate name, a bound no answer satisfies, a
1099
+ * breached budget — is {@link auditSchema}'s question.
988
1100
  *
989
1101
  * @param input - The value to inspect.
990
- * @returns Whether the value is a structurally valid form schema.
1102
+ * @returns True if the value is a structurally valid form schema; false otherwise.
991
1103
  */
992
1104
  export declare function isFormSchema(input: unknown): input is FormSchema;
993
1105
 
994
1106
  /**
995
- * Determine whether an unknown value is a form lifecycle status.
1107
+ * Determines whether an unknown value is a form lifecycle status.
996
1108
  *
997
1109
  * @param input - The value to inspect.
998
- * @returns Whether the value is a form status.
1110
+ * @returns True if the value is a form status; false otherwise.
999
1111
  */
1000
1112
  export declare function isFormStatus(input: unknown): input is FormStatus;
1001
1113
 
1002
1114
  /**
1003
- * Determine whether an unknown value is a record of field values.
1115
+ * Determines whether an unknown value is a record of field values.
1004
1116
  *
1005
1117
  * @param input - The value to inspect.
1006
- * @returns Whether the value is a form values record.
1118
+ * @returns True if the value is a form values record; false otherwise.
1007
1119
  */
1008
1120
  export declare function isFormValues(input: unknown): input is FormValues;
1009
1121
 
1010
- /** The maximum number of entries one list-valued answer may hold. */
1122
+ /** Caps the number of entries one list-valued answer may hold, at 1024. */
1011
1123
  export declare const LIST_LIMIT = 1024;
1012
1124
 
1013
1125
  /**
1014
- * Decide whether a raw binding value projects to an answered field.
1126
+ * Decides whether a raw binding value projects to an answered field.
1015
1127
  *
1016
1128
  * @remarks
1017
1129
  * Bind with `fill(name, matchesAnswer(raw) ? raw : undefined)`. This projection treats an absent
@@ -1020,44 +1132,48 @@ export declare const LIST_LIMIT = 1024;
1020
1132
  * its `required` rule remains presence-only.
1021
1133
  *
1022
1134
  * @param value - The raw field value, or absence.
1023
- * @returns Whether the binding should preserve the value as an answer.
1135
+ * @returns True if the binding preserves the value as an answer; false otherwise.
1024
1136
  */
1025
1137
  export declare function matchesAnswer(value: FieldValue | undefined): boolean;
1026
1138
 
1027
1139
  /**
1028
- * Check whether a value has the shape required by one field control.
1140
+ * Checks whether a value has the shape required by one field control.
1141
+ *
1142
+ * @remarks
1143
+ * Every write and every seeded value passes through this gate, and it reads `STRING_LIMIT` and
1144
+ * `LIST_LIMIT` before it consults the control, so no regular expression sees an over-long value.
1029
1145
  *
1030
1146
  * @param field - The field that owns the value.
1031
1147
  * @param value - The unknown value to inspect.
1032
- * @returns Whether the control can hold the value.
1148
+ * @returns True if the control can hold the value; false otherwise.
1033
1149
  */
1034
1150
  export declare function matchesField(field: FormField, value: unknown): value is FieldValue;
1035
1151
 
1036
1152
  /**
1037
- * Compare two field values by scalar identity or ordered list content.
1153
+ * Compares two field values by scalar identity or ordered list content.
1038
1154
  *
1039
1155
  * @param a - The first field value.
1040
1156
  * @param b - The second field value.
1041
- * @returns Whether both values contain the same answer.
1157
+ * @returns True if both values contain the same answer; false otherwise.
1042
1158
  */
1043
1159
  export declare function matchesValue(a: FieldValue, b: FieldValue): boolean;
1044
1160
 
1045
1161
  /**
1046
- * Compare two form value records by keys and value content.
1162
+ * Compares two form value records by keys and value content.
1047
1163
  *
1048
1164
  * @param a - The first value record.
1049
1165
  * @param b - The second value record.
1050
- * @returns Whether both records contain the same answers.
1166
+ * @returns True if both records contain the same answers; false otherwise.
1051
1167
  */
1052
1168
  export declare function matchesValues(a: FormValues, b: FormValues): boolean;
1053
1169
 
1054
- /** The maximum length, in UTF-16 code units, of a schema, group, or field name. */
1170
+ /** Caps the length, in UTF-16 code units, of a schema, group, or field name, at 128. */
1055
1171
  export declare const NAME_LIMIT = 128;
1056
1172
 
1057
- /** The maximum total number of records, arrays, and leaves one schema retains. */
1173
+ /** Caps the total number of records, arrays, and leaves one schema retains, at 16384. */
1058
1174
  export declare const NODE_LIMIT = 16384;
1059
1175
 
1060
- /** A number. */
1176
+ /** Represents a number. */
1061
1177
  export declare interface NumberField extends FieldBase {
1062
1178
  readonly control: 'number';
1063
1179
  readonly default?: number;
@@ -1065,7 +1181,7 @@ export declare interface NumberField extends FieldBase {
1065
1181
  }
1066
1182
 
1067
1183
  /**
1068
- * Parse unknown wire data into an owned, semantically sound form schema.
1184
+ * Parses unknown wire data into an owned, semantically sound form schema.
1069
1185
  *
1070
1186
  * @param input - The unknown schema value to parse.
1071
1187
  * @returns An owned schema with custom rules removed, or `undefined` on refusal.
@@ -1073,7 +1189,11 @@ export declare interface NumberField extends FieldBase {
1073
1189
  export declare function parseForm(input: unknown): FormSchema | undefined;
1074
1190
 
1075
1191
  /**
1076
- * Parse one answer against its field control.
1192
+ * Parses one answer against its field control.
1193
+ *
1194
+ * @remarks
1195
+ * A numeric string coerces to a number for a `number` field, and `'true'` and `'false'` coerce to
1196
+ * a boolean for a `confirm` field. Every other value must already have its control's shape.
1077
1197
  *
1078
1198
  * @param field - The field that defines the accepted value.
1079
1199
  * @param input - The unknown value to parse.
@@ -1082,7 +1202,7 @@ export declare function parseForm(input: unknown): FormSchema | undefined;
1082
1202
  export declare function parseValue(field: FormField, input: unknown): FieldValue | undefined;
1083
1203
 
1084
1204
  /**
1085
- * Parse a strict answer record against the fields declared by a schema.
1205
+ * Parses a strict answer record against the fields declared by a schema.
1086
1206
  *
1087
1207
  * @param schema - The schema that owns the accepted field names and controls.
1088
1208
  * @param input - The unknown answer record to parse.
@@ -1091,7 +1211,7 @@ export declare function parseValue(field: FormField, input: unknown): FieldValue
1091
1211
  export declare function parseValues(schema: FormSchema, input: unknown): FormValues | undefined;
1092
1212
 
1093
1213
  /**
1094
- * A secret, obscured as it is typed.
1214
+ * Represents a secret, obscured as it is typed.
1095
1215
  *
1096
1216
  * @remarks
1097
1217
  * It carries no `default` deliberately: a seeded secret is a secret written down. `mask` is
@@ -1102,14 +1222,14 @@ export declare interface PasswordField extends FieldBase {
1102
1222
  readonly mask?: string;
1103
1223
  }
1104
1224
 
1105
- /** The maximum accepted source length for an authored regular expression. */
1225
+ /** Caps the accepted source length for an authored regular expression, at 256. */
1106
1226
  export declare const PATTERN_LIMIT = 256;
1107
1227
 
1108
- /** Default failure copy for every named field rule. */
1228
+ /** Holds the default failure copy for every named field rule. */
1109
1229
  export declare const RULE_MESSAGES: Readonly<Record<FieldRuleName, string>>;
1110
1230
 
1111
1231
  /**
1112
- * One choice out of a list.
1232
+ * Represents one choice out of a list.
1113
1233
  *
1114
1234
  * @remarks
1115
1235
  * `open` admits a value the list does not offer, which is what turns a closed menu into a
@@ -1123,7 +1243,7 @@ export declare interface SelectField extends FieldBase {
1123
1243
  }
1124
1244
 
1125
1245
  /**
1126
- * Project a schema into JSON while removing custom validators and absent values.
1246
+ * Projects a schema into JSON while removing custom validators and absent values.
1127
1247
  *
1128
1248
  * @param schema - The schema to project.
1129
1249
  * @returns A deep JSON copy of the serializable schema.
@@ -1132,29 +1252,29 @@ export declare interface SelectField extends FieldBase {
1132
1252
  */
1133
1253
  export declare function serializeForm(schema: FormSchema): JSONRecord;
1134
1254
 
1135
- /** The maximum length, in UTF-16 code units, of any single retained string. */
1255
+ /** Caps the length, in UTF-16 code units, of any single retained string, at 65536. */
1136
1256
  export declare const STRING_LIMIT = 65536;
1137
1257
 
1138
- /** The maximum total length, in UTF-16 code units, of every string one schema retains. */
1258
+ /** Caps the total length, in UTF-16 code units, of every string one schema retains, at 1048576. */
1139
1259
  export declare const TEXT_LIMIT = 1048576;
1140
1260
 
1141
- /** A single line of text. */
1261
+ /** Represents a single line of text. */
1142
1262
  export declare interface TextField extends FieldBase {
1143
1263
  readonly control: 'text';
1144
1264
  readonly default?: string;
1145
1265
  readonly placeholder?: string;
1146
1266
  }
1147
1267
 
1148
- /** A 24-hour time string with optional seconds. */
1268
+ /** Matches a 24-hour time string with optional seconds. */
1149
1269
  export declare const TIME_PATTERN: Readonly<RegExp>;
1150
1270
 
1151
- /** A time of day, held as the control's own string. */
1271
+ /** Represents a time of day, held as the control's own `HH:MM` string, with seconds optional. */
1152
1272
  export declare interface TimeField extends FieldBase {
1153
1273
  readonly control: 'time';
1154
1274
  readonly default?: string;
1155
1275
  }
1156
1276
 
1157
- /** An absolute HTTP or HTTPS URL shape. */
1277
+ /** Matches an absolute HTTP or HTTPS URL shape. */
1158
1278
  export declare const URL_PATTERN: Readonly<RegExp>;
1159
1279
 
1160
1280
  export { }