@orkestrel/contract 0.0.22 → 0.0.23

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.
@@ -418,8 +418,10 @@ export declare function buildSampleMemo(): SampleMemo;
418
418
  * OBTAIN the string — the reporter coerces through `parseString`, the auditor
419
419
  * demands a primitive string — and share every constraint afterwards through
420
420
  * this helper, so a constraint cannot drift between them.
421
- * Faults come out in declaration order — `min`, then `max`, then
421
+ * Faults come out in declaration order — `date`, then `min`, then `max`, then
422
422
  * `pattern` — because a report is read top to bottom and its order is public.
423
+ * `expected` is `'date'` on a date string shape and `'string'` otherwise, as
424
+ * {@link buildNumberFaults} names `'integer'`.
423
425
  *
424
426
  * The declaration's pattern is applied through an OWNED stateless rebuild
425
427
  * ({@link readPattern}) asked through {@link matchesPattern}, so the shape's own
@@ -1066,6 +1068,25 @@ export declare function compileSchema(shape: ContractShape): JSONSchema;
1066
1068
  */
1067
1069
  export declare function complementOf<TBase, TExcluded extends TBase>(base: Guard<TBase>, excluded: Guard<TExcluded> | ((value: TBase) => value is TExcluded)): Guard<Exclude<TBase, TExcluded>>;
1068
1070
 
1071
+ /**
1072
+ * Computes the number of days in a month of the Gregorian calendar.
1073
+ *
1074
+ * @remarks
1075
+ * February has 29 days in a year divisible by 4, except a century year not divisible
1076
+ * by 400. The caller supplies a month from 1 to 12.
1077
+ *
1078
+ * @param year - The calendar year
1079
+ * @param month - The month, from 1 for January to 12 for December
1080
+ * @returns The days in that month, from 28 to 31
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * computeMonthLength(2024, 2) // 29
1085
+ * computeMonthLength(1900, 2) // 28
1086
+ * ```
1087
+ */
1088
+ export declare function computeMonthLength(year: number, month: number): number;
1089
+
1069
1090
  /**
1070
1091
  * Counts the surrogate pairs in a string, stopping at a limit.
1071
1092
  *
@@ -1633,6 +1654,40 @@ export declare function createContract<S extends ContractShape>(shape: S): Contr
1633
1654
 
1634
1655
  export declare function createContract(shape: ContractShape): ContractInterface<unknown>;
1635
1656
 
1657
+ /**
1658
+ * Holds `10`, the length of every `YYYY-MM-DD` date a date string shape admits.
1659
+ *
1660
+ * @remarks
1661
+ * A date string shape whose `min` or `max` excludes this length admits no value, so
1662
+ * building one refuses with code `range`.
1663
+ *
1664
+ * @example
1665
+ * ```ts
1666
+ * DATE_LENGTH // 10
1667
+ * ```
1668
+ */
1669
+ export declare const DATE_LENGTH = 10;
1670
+
1671
+ /**
1672
+ * Builds a calendar-date {@link StringShape} — forces `date: true`.
1673
+ *
1674
+ * @remarks
1675
+ * The guard and the parser admit exactly a calendar-valid `YYYY-MM-DD` and coerce
1676
+ * nothing, so `2026-02-30`, `2026-1-10`, and a date-time all refuse. The emitted JSON
1677
+ * Schema carries `"format": "date"`. Options other than `min`, `max`, and `description`
1678
+ * refuse, because a dropped `pattern` would widen the shape.
1679
+ *
1680
+ * @param options - Optional length bounds and `description` (no `date` or `pattern` key)
1681
+ * @returns A date string shape
1682
+ * @throws {ContractError} When an option key is unknown, or a present bound is invalid or excludes length 10
1683
+ *
1684
+ * @example
1685
+ * ```ts
1686
+ * createContract(dateShape()).is('2024-02-29') // true
1687
+ * ```
1688
+ */
1689
+ export declare function dateShape(options?: Omit<StringShapeOptions, 'date' | 'pattern'>): StringShape;
1690
+
1636
1691
  /**
1637
1692
  * Derives `min`/`max` shape bounds from a pair of non-negative-integer JSON
1638
1693
  * Schema length keywords (`minLength`/`maxLength`, `minItems`/`maxItems`).
@@ -2013,7 +2068,7 @@ export declare function failure<E>(error: E): Failure<E>;
2013
2068
  * - `'type'` — the value could not coerce to `expected` at all.
2014
2069
  * - `'missing'` — a required object property was absent.
2015
2070
  * - `'constraint'` — the value coerced to `expected` but violated one
2016
- * refinement (`min` / `max` / `pattern` / `integer`); `limit` carries the
2071
+ * refinement (`min` / `max` / `pattern` / `date` / `integer`); `limit` carries the
2017
2072
  * violated bound/pattern when applicable.
2018
2073
  * - `'variant'` — an `anyOf`-mode union matched no variant; `variants` is the
2019
2074
  * variant count, followed (in the report) by the closest variant's own faults.
@@ -2108,19 +2163,19 @@ export declare const FAULT_TEXT_LIMIT = 2048;
2108
2163
  * Names the refinement a {@link Fault} of reason `'constraint'` violates.
2109
2164
  *
2110
2165
  * @remarks
2111
- * The vocabulary is `'min'`, `'max'`, `'pattern'`, and `'integer'`.
2166
+ * The vocabulary is `'min'`, `'max'`, `'pattern'`, `'date'`, and `'integer'`.
2112
2167
  */
2113
- export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'integer';
2168
+ export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'integer';
2114
2169
 
2115
2170
  /**
2116
2171
  * Names the kind of value a {@link Fault} expected — the shape-projected counterpart of
2117
2172
  * a `ContractShape`'s `category`.
2118
2173
  *
2119
2174
  * @remarks
2120
- * The vocabulary is `'string'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2175
+ * The vocabulary is `'string'`, `'date'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2121
2176
  * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, and `'shape'`.
2122
2177
  */
2123
- export declare type FaultKind = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape';
2178
+ export declare type FaultKind = 'string' | 'date' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape';
2124
2179
 
2125
2180
  /**
2126
2181
  * Retains a lazily built fault declaration without building shapes during module evaluation.
@@ -4495,6 +4550,26 @@ export declare function mapOf<K, V>(keyGuard: Guard<K>, valueGuard: Guard<V>): G
4495
4550
 
4496
4551
  export declare function mapOf(keyPredicate: (value: unknown) => boolean, valuePredicate: (value: unknown) => boolean): Guard<ReadonlyMap<unknown, unknown>>;
4497
4552
 
4553
+ /**
4554
+ * Checks whether a string is exactly a calendar-valid `YYYY-MM-DD` date.
4555
+ *
4556
+ * @remarks
4557
+ * Refuses a date-time, surrounding whitespace, and a date the Gregorian calendar
4558
+ * lacks, such as `2026-02-29`. Backs a date string shape and {@link classifyFormat}'s
4559
+ * `date`.
4560
+ *
4561
+ * @param value - The candidate string
4562
+ * @returns True if `value` is a calendar-valid `YYYY-MM-DD`; false otherwise
4563
+ * @throws The exact value thrown by a redirected pattern dispatch
4564
+ *
4565
+ * @example
4566
+ * ```ts
4567
+ * matchesCalendarDate('2024-02-29') // true
4568
+ * matchesCalendarDate('2026-02-29') // false
4569
+ * ```
4570
+ */
4571
+ export declare function matchesCalendarDate(value: string): boolean;
4572
+
4498
4573
  /**
4499
4574
  * Determines whether an object holds exactly the named own keys.
4500
4575
  *
@@ -6320,7 +6395,7 @@ export declare function refuseOptionKeys(source: object | undefined, keys: reado
6320
6395
  *
6321
6396
  * @remarks
6322
6397
  * An object lists its required keys first and marks the rest with `?`, at most `FAULT_LIST_LIMIT`
6323
- * of them. A leaf or array keeps its numeric bounds and pattern, a union joins its forms with ` | `,
6398
+ * of them. A leaf or array keeps its numeric bounds, pattern, and format, a union joins its forms with ` | `,
6324
6399
  * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and
6325
6400
  * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past
6326
6401
  * `room` is cut and closes with `…`. A type word outside JSON Schema's vocabulary is encoded.
@@ -6804,15 +6879,18 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
6804
6879
  *
6805
6880
  * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with
6806
6881
  * code `structure`, every node the lenient walk would widen, every keyword it
6807
- * would ignore (`pattern`, `format`, `nullable`, `patternProperties`,
6808
- * `propertyNames`, `prefixItems`, and anything else outside
6882
+ * would ignore (`pattern`, every `format` but `'date'` on a string node, `nullable`,
6883
+ * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside
6809
6884
  * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry
6810
- * that is neither a finite primitive nor `null`, a contradictory bound, a `required` name not in
6885
+ * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose
6886
+ * length bounds exclude length 10, a `required` name not in
6811
6887
  * `properties`, breadth past {@link INFER_BREADTH_LIMIT}, and a `default` with no
6812
6888
  * optional property to fill. An object with no `additionalProperties` closes
6813
6889
  * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads
6814
6890
  * every keyword that could keep two arms apart. Below a `oneOf` that object refuses
6815
- * instead, since closing it could change which arms match.
6891
+ * instead, since closing it could change which arms match. A strict conversion is the
6892
+ * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a
6893
+ * date string shape, so a compiled {@link dateShape} round-trips.
6816
6894
  *
6817
6895
  * @param schema - The JSON Schema value to convert
6818
6896
  * @param options - Optional `strict`, default `false`
@@ -7078,7 +7156,8 @@ export declare interface ShapeShapeOptions {
7078
7156
  * A structural mapping used by {@link compileReporter} to fill a `Fault`'s
7079
7157
  * `expected` field and by {@link compileAuditor} to fill an `AuditFault`'s:
7080
7158
  * most shapes map to their own `category` (`numberShape` maps to
7081
- * `'integer'` when `integer: true`, else `'number'`); `optionalShape` /
7159
+ * `'integer'` when `integer: true`, else `'number'`, and `stringShape` maps to
7160
+ * `'date'` when `date: true`, else `'string'`); `optionalShape` /
7082
7161
  * `nullableShape` project through to their inner shape's kind, and `rawShape`
7083
7162
  * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.
7084
7163
  *
@@ -7221,7 +7300,9 @@ export declare function sortValues<T extends string | number>(values: readonly T
7221
7300
  * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,
7222
7301
  * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.
7223
7302
  * `pattern` and `format` are absent because no compiled shape asserts them, so a
7224
- * schema holding one would convert to a shape wider than the schema it came from.
7303
+ * schema holding one would convert to a shape wider than the schema it came from. The
7304
+ * one exception is `format: 'date'` on a string node, which a strict conversion reads
7305
+ * as a date string shape.
7225
7306
  *
7226
7307
  * @example
7227
7308
  * ```ts
@@ -7250,9 +7331,9 @@ export declare const STRING_LIMIT = 65536;
7250
7331
  *
7251
7332
  * @remarks
7252
7333
  * The refinement half of {@link StringShapeOptions}: the same `min`, `max`, and
7253
- * `pattern` members, without the `description` a shape carries for its emitted
7254
- * schema. A guard publishes no description, so the two surfaces share the
7255
- * refinements and nothing else.
7334
+ * `pattern` members, without the `date` flag and the `description` a shape
7335
+ * carries for its emitted schema. A compiled date shape composes this guard with
7336
+ * {@link matchesCalendarDate}.
7256
7337
  */
7257
7338
  export declare interface StringGuardOptions {
7258
7339
  readonly min?: number;
@@ -7290,11 +7371,13 @@ export declare interface StringGuardOptions {
7290
7371
  export declare function stringOf(options?: StringGuardOptions): Guard<string>;
7291
7372
 
7292
7373
  /**
7293
- * Describes a string with optional length and pattern constraints.
7374
+ * Describes a string with optional length, pattern, and calendar-date constraints.
7294
7375
  *
7295
7376
  * @remarks
7296
7377
  * `min` and `max` count code points, as the `minLength` and `maxLength` the shape
7297
- * emits do, so one astral character has a length of one.
7378
+ * emits do, so one astral character has a length of one. `date` restricts the string
7379
+ * to a calendar-valid `YYYY-MM-DD` and emits `format: 'date'`; a shape that declares
7380
+ * `date` declares no `pattern`.
7298
7381
  */
7299
7382
  export declare interface StringShape {
7300
7383
  readonly category: 'string';
@@ -7305,6 +7388,7 @@ export declare interface StringShape {
7305
7388
  * Builders and cloners expose an owned fresh frozen zero-state copy per read.
7306
7389
  */
7307
7390
  readonly pattern?: RegExp;
7391
+ readonly date?: boolean;
7308
7392
  readonly description?: string;
7309
7393
  }
7310
7394
 
@@ -7315,10 +7399,12 @@ export declare interface StringShape {
7315
7399
  * A supplied pattern is captured by source and flags. The shape exposes a fresh
7316
7400
  * frozen zero-state `RegExp` on every `pattern` read, so neither the caller's
7317
7401
  * original nor a value read from the shape can drift later compiled artifacts.
7402
+ * `date: true` restricts the string to a calendar-valid `YYYY-MM-DD`, as
7403
+ * {@link dateShape} builds it.
7318
7404
  *
7319
- * @param options - Optional length (`min` / `max`), `pattern`, and `description`
7405
+ * @param options - Optional length (`min` / `max`), `pattern`, `date`, and `description`
7320
7406
  * @returns A string shape
7321
- * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, or `pattern` has flags
7407
+ * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, `pattern` has flags, `date` is not a boolean, or `date` meets `pattern` or a bound that excludes length 10
7322
7408
  *
7323
7409
  * @example
7324
7410
  * ```ts
@@ -7332,6 +7418,7 @@ export declare interface StringShapeOptions {
7332
7418
  readonly min?: number;
7333
7419
  readonly max?: number;
7334
7420
  readonly pattern?: RegExp;
7421
+ readonly date?: boolean;
7335
7422
  readonly description?: string;
7336
7423
  }
7337
7424
 
@@ -418,8 +418,10 @@ export declare function buildSampleMemo(): SampleMemo;
418
418
  * OBTAIN the string — the reporter coerces through `parseString`, the auditor
419
419
  * demands a primitive string — and share every constraint afterwards through
420
420
  * this helper, so a constraint cannot drift between them.
421
- * Faults come out in declaration order — `min`, then `max`, then
421
+ * Faults come out in declaration order — `date`, then `min`, then `max`, then
422
422
  * `pattern` — because a report is read top to bottom and its order is public.
423
+ * `expected` is `'date'` on a date string shape and `'string'` otherwise, as
424
+ * {@link buildNumberFaults} names `'integer'`.
423
425
  *
424
426
  * The declaration's pattern is applied through an OWNED stateless rebuild
425
427
  * ({@link readPattern}) asked through {@link matchesPattern}, so the shape's own
@@ -1066,6 +1068,25 @@ export declare function compileSchema(shape: ContractShape): JSONSchema;
1066
1068
  */
1067
1069
  export declare function complementOf<TBase, TExcluded extends TBase>(base: Guard<TBase>, excluded: Guard<TExcluded> | ((value: TBase) => value is TExcluded)): Guard<Exclude<TBase, TExcluded>>;
1068
1070
 
1071
+ /**
1072
+ * Computes the number of days in a month of the Gregorian calendar.
1073
+ *
1074
+ * @remarks
1075
+ * February has 29 days in a year divisible by 4, except a century year not divisible
1076
+ * by 400. The caller supplies a month from 1 to 12.
1077
+ *
1078
+ * @param year - The calendar year
1079
+ * @param month - The month, from 1 for January to 12 for December
1080
+ * @returns The days in that month, from 28 to 31
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * computeMonthLength(2024, 2) // 29
1085
+ * computeMonthLength(1900, 2) // 28
1086
+ * ```
1087
+ */
1088
+ export declare function computeMonthLength(year: number, month: number): number;
1089
+
1069
1090
  /**
1070
1091
  * Counts the surrogate pairs in a string, stopping at a limit.
1071
1092
  *
@@ -1633,6 +1654,40 @@ export declare function createContract<S extends ContractShape>(shape: S): Contr
1633
1654
 
1634
1655
  export declare function createContract(shape: ContractShape): ContractInterface<unknown>;
1635
1656
 
1657
+ /**
1658
+ * Holds `10`, the length of every `YYYY-MM-DD` date a date string shape admits.
1659
+ *
1660
+ * @remarks
1661
+ * A date string shape whose `min` or `max` excludes this length admits no value, so
1662
+ * building one refuses with code `range`.
1663
+ *
1664
+ * @example
1665
+ * ```ts
1666
+ * DATE_LENGTH // 10
1667
+ * ```
1668
+ */
1669
+ export declare const DATE_LENGTH = 10;
1670
+
1671
+ /**
1672
+ * Builds a calendar-date {@link StringShape} — forces `date: true`.
1673
+ *
1674
+ * @remarks
1675
+ * The guard and the parser admit exactly a calendar-valid `YYYY-MM-DD` and coerce
1676
+ * nothing, so `2026-02-30`, `2026-1-10`, and a date-time all refuse. The emitted JSON
1677
+ * Schema carries `"format": "date"`. Options other than `min`, `max`, and `description`
1678
+ * refuse, because a dropped `pattern` would widen the shape.
1679
+ *
1680
+ * @param options - Optional length bounds and `description` (no `date` or `pattern` key)
1681
+ * @returns A date string shape
1682
+ * @throws {ContractError} When an option key is unknown, or a present bound is invalid or excludes length 10
1683
+ *
1684
+ * @example
1685
+ * ```ts
1686
+ * createContract(dateShape()).is('2024-02-29') // true
1687
+ * ```
1688
+ */
1689
+ export declare function dateShape(options?: Omit<StringShapeOptions, 'date' | 'pattern'>): StringShape;
1690
+
1636
1691
  /**
1637
1692
  * Derives `min`/`max` shape bounds from a pair of non-negative-integer JSON
1638
1693
  * Schema length keywords (`minLength`/`maxLength`, `minItems`/`maxItems`).
@@ -2013,7 +2068,7 @@ export declare function failure<E>(error: E): Failure<E>;
2013
2068
  * - `'type'` — the value could not coerce to `expected` at all.
2014
2069
  * - `'missing'` — a required object property was absent.
2015
2070
  * - `'constraint'` — the value coerced to `expected` but violated one
2016
- * refinement (`min` / `max` / `pattern` / `integer`); `limit` carries the
2071
+ * refinement (`min` / `max` / `pattern` / `date` / `integer`); `limit` carries the
2017
2072
  * violated bound/pattern when applicable.
2018
2073
  * - `'variant'` — an `anyOf`-mode union matched no variant; `variants` is the
2019
2074
  * variant count, followed (in the report) by the closest variant's own faults.
@@ -2108,19 +2163,19 @@ export declare const FAULT_TEXT_LIMIT = 2048;
2108
2163
  * Names the refinement a {@link Fault} of reason `'constraint'` violates.
2109
2164
  *
2110
2165
  * @remarks
2111
- * The vocabulary is `'min'`, `'max'`, `'pattern'`, and `'integer'`.
2166
+ * The vocabulary is `'min'`, `'max'`, `'pattern'`, `'date'`, and `'integer'`.
2112
2167
  */
2113
- export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'integer';
2168
+ export declare type FaultConstraint = 'min' | 'max' | 'pattern' | 'date' | 'integer';
2114
2169
 
2115
2170
  /**
2116
2171
  * Names the kind of value a {@link Fault} expected — the shape-projected counterpart of
2117
2172
  * a `ContractShape`'s `category`.
2118
2173
  *
2119
2174
  * @remarks
2120
- * The vocabulary is `'string'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2175
+ * The vocabulary is `'string'`, `'date'`, `'number'`, `'integer'`, `'boolean'`, `'null'`,
2121
2176
  * `'literal'`, `'array'`, `'object'`, `'union'`, `'json'`, and `'shape'`.
2122
2177
  */
2123
- export declare type FaultKind = 'string' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape';
2178
+ export declare type FaultKind = 'string' | 'date' | 'number' | 'integer' | 'boolean' | 'null' | 'literal' | 'array' | 'object' | 'union' | 'json' | 'shape';
2124
2179
 
2125
2180
  /**
2126
2181
  * Retains a lazily built fault declaration without building shapes during module evaluation.
@@ -4495,6 +4550,26 @@ export declare function mapOf<K, V>(keyGuard: Guard<K>, valueGuard: Guard<V>): G
4495
4550
 
4496
4551
  export declare function mapOf(keyPredicate: (value: unknown) => boolean, valuePredicate: (value: unknown) => boolean): Guard<ReadonlyMap<unknown, unknown>>;
4497
4552
 
4553
+ /**
4554
+ * Checks whether a string is exactly a calendar-valid `YYYY-MM-DD` date.
4555
+ *
4556
+ * @remarks
4557
+ * Refuses a date-time, surrounding whitespace, and a date the Gregorian calendar
4558
+ * lacks, such as `2026-02-29`. Backs a date string shape and {@link classifyFormat}'s
4559
+ * `date`.
4560
+ *
4561
+ * @param value - The candidate string
4562
+ * @returns True if `value` is a calendar-valid `YYYY-MM-DD`; false otherwise
4563
+ * @throws The exact value thrown by a redirected pattern dispatch
4564
+ *
4565
+ * @example
4566
+ * ```ts
4567
+ * matchesCalendarDate('2024-02-29') // true
4568
+ * matchesCalendarDate('2026-02-29') // false
4569
+ * ```
4570
+ */
4571
+ export declare function matchesCalendarDate(value: string): boolean;
4572
+
4498
4573
  /**
4499
4574
  * Determines whether an object holds exactly the named own keys.
4500
4575
  *
@@ -6320,7 +6395,7 @@ export declare function refuseOptionKeys(source: object | undefined, keys: reado
6320
6395
  *
6321
6396
  * @remarks
6322
6397
  * An object lists its required keys first and marks the rest with `?`, at most `FAULT_LIST_LIMIT`
6323
- * of them. A leaf or array keeps its numeric bounds and pattern, a union joins its forms with ` | `,
6398
+ * of them. A leaf or array keeps its numeric bounds, pattern, and format, a union joins its forms with ` | `,
6324
6399
  * and a schema that says nothing reads `any`. Each nested form takes half the room of its parent, and
6325
6400
  * below 16 characters a form stops at its type, so a schema that holds itself still ends. Text past
6326
6401
  * `room` is cut and closes with `…`. A type word outside JSON Schema's vocabulary is encoded.
@@ -6804,15 +6879,18 @@ export declare function schemaToParameters(schema: JSONSchema): Readonly<Record<
6804
6879
  *
6805
6880
  * STRICT: `{ strict: true }` is the door for a foreign schema. It refuses, with
6806
6881
  * code `structure`, every node the lenient walk would widen, every keyword it
6807
- * would ignore (`pattern`, `format`, `nullable`, `patternProperties`,
6808
- * `propertyNames`, `prefixItems`, and anything else outside
6882
+ * would ignore (`pattern`, every `format` but `'date'` on a string node, `nullable`,
6883
+ * `patternProperties`, `propertyNames`, `prefixItems`, and anything else outside
6809
6884
  * {@link STRICT_SCHEMA_KEYWORDS}), a malformed keyword or annotation, a boolean schema, an `enum` entry
6810
- * that is neither a finite primitive nor `null`, a contradictory bound, a `required` name not in
6885
+ * that is neither a finite primitive nor `null`, a contradictory bound, a date format whose
6886
+ * length bounds exclude length 10, a `required` name not in
6811
6887
  * `properties`, breadth past {@link INFER_BREADTH_LIMIT}, and a `default` with no
6812
6888
  * optional property to fill. An object with no `additionalProperties` closes
6813
6889
  * rather than opens, and `oneOf` keeps exactly-one, because a strict walk reads
6814
6890
  * every keyword that could keep two arms apart. Below a `oneOf` that object refuses
6815
- * instead, since closing it could change which arms match.
6891
+ * instead, since closing it could change which arms match. A strict conversion is the
6892
+ * one walk that asserts a `format`: it reads `format: 'date'` on a string node as a
6893
+ * date string shape, so a compiled {@link dateShape} round-trips.
6816
6894
  *
6817
6895
  * @param schema - The JSON Schema value to convert
6818
6896
  * @param options - Optional `strict`, default `false`
@@ -7078,7 +7156,8 @@ export declare interface ShapeShapeOptions {
7078
7156
  * A structural mapping used by {@link compileReporter} to fill a `Fault`'s
7079
7157
  * `expected` field and by {@link compileAuditor} to fill an `AuditFault`'s:
7080
7158
  * most shapes map to their own `category` (`numberShape` maps to
7081
- * `'integer'` when `integer: true`, else `'number'`); `optionalShape` /
7159
+ * `'integer'` when `integer: true`, else `'number'`, and `stringShape` maps to
7160
+ * `'date'` when `date: true`, else `'string'`); `optionalShape` /
7082
7161
  * `nullableShape` project through to their inner shape's kind, and `rawShape`
7083
7162
  * (an arbitrary embedded schema with no fixed kind) projects to `'json'`.
7084
7163
  *
@@ -7221,7 +7300,9 @@ export declare function sortValues<T extends string | number>(values: readonly T
7221
7300
  * lose nothing when a shape drops them: `title`, `$schema`, `$id`, `$comment`,
7222
7301
  * `examples`, `deprecated`, `readOnly`, and `writeOnly`. Every other keyword refuses.
7223
7302
  * `pattern` and `format` are absent because no compiled shape asserts them, so a
7224
- * schema holding one would convert to a shape wider than the schema it came from.
7303
+ * schema holding one would convert to a shape wider than the schema it came from. The
7304
+ * one exception is `format: 'date'` on a string node, which a strict conversion reads
7305
+ * as a date string shape.
7225
7306
  *
7226
7307
  * @example
7227
7308
  * ```ts
@@ -7250,9 +7331,9 @@ export declare const STRING_LIMIT = 65536;
7250
7331
  *
7251
7332
  * @remarks
7252
7333
  * The refinement half of {@link StringShapeOptions}: the same `min`, `max`, and
7253
- * `pattern` members, without the `description` a shape carries for its emitted
7254
- * schema. A guard publishes no description, so the two surfaces share the
7255
- * refinements and nothing else.
7334
+ * `pattern` members, without the `date` flag and the `description` a shape
7335
+ * carries for its emitted schema. A compiled date shape composes this guard with
7336
+ * {@link matchesCalendarDate}.
7256
7337
  */
7257
7338
  export declare interface StringGuardOptions {
7258
7339
  readonly min?: number;
@@ -7290,11 +7371,13 @@ export declare interface StringGuardOptions {
7290
7371
  export declare function stringOf(options?: StringGuardOptions): Guard<string>;
7291
7372
 
7292
7373
  /**
7293
- * Describes a string with optional length and pattern constraints.
7374
+ * Describes a string with optional length, pattern, and calendar-date constraints.
7294
7375
  *
7295
7376
  * @remarks
7296
7377
  * `min` and `max` count code points, as the `minLength` and `maxLength` the shape
7297
- * emits do, so one astral character has a length of one.
7378
+ * emits do, so one astral character has a length of one. `date` restricts the string
7379
+ * to a calendar-valid `YYYY-MM-DD` and emits `format: 'date'`; a shape that declares
7380
+ * `date` declares no `pattern`.
7298
7381
  */
7299
7382
  export declare interface StringShape {
7300
7383
  readonly category: 'string';
@@ -7305,6 +7388,7 @@ export declare interface StringShape {
7305
7388
  * Builders and cloners expose an owned fresh frozen zero-state copy per read.
7306
7389
  */
7307
7390
  readonly pattern?: RegExp;
7391
+ readonly date?: boolean;
7308
7392
  readonly description?: string;
7309
7393
  }
7310
7394
 
@@ -7315,10 +7399,12 @@ export declare interface StringShape {
7315
7399
  * A supplied pattern is captured by source and flags. The shape exposes a fresh
7316
7400
  * frozen zero-state `RegExp` on every `pattern` read, so neither the caller's
7317
7401
  * original nor a value read from the shape can drift later compiled artifacts.
7402
+ * `date: true` restricts the string to a calendar-valid `YYYY-MM-DD`, as
7403
+ * {@link dateShape} builds it.
7318
7404
  *
7319
- * @param options - Optional length (`min` / `max`), `pattern`, and `description`
7405
+ * @param options - Optional length (`min` / `max`), `pattern`, `date`, and `description`
7320
7406
  * @returns A string shape
7321
- * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, or `pattern` has flags
7407
+ * @throws {ContractError} When a present bound is invalid, `pattern` is not a `RegExp`, `pattern` has flags, `date` is not a boolean, or `date` meets `pattern` or a bound that excludes length 10
7322
7408
  *
7323
7409
  * @example
7324
7410
  * ```ts
@@ -7332,6 +7418,7 @@ export declare interface StringShapeOptions {
7332
7418
  readonly min?: number;
7333
7419
  readonly max?: number;
7334
7420
  readonly pattern?: RegExp;
7421
+ readonly date?: boolean;
7335
7422
  readonly description?: string;
7336
7423
  }
7337
7424