@atscript/typescript 0.1.107 → 0.1.108

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,12 +1,27 @@
1
1
 
2
2
  //#region packages/typescript/src/runtime/validator-fast-check.ts
3
+ function _define_property$1(obj, key, value) {
4
+ if (key in obj) Object.defineProperty(obj, key, {
5
+ value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ else obj[key] = value;
11
+ return obj;
12
+ }
3
13
  /**
4
14
  * Allocation-free boolean pre-check used by {@link Validator.validate} before the
5
15
  * error-collecting walk.
6
16
  *
7
- * It reads the type tree and metadata LIVE on every call (nothing derived from the
8
- * type is cached), so `annotate()` / `metadata.set()` / prop mutations made after a
9
- * validator was created are always honoured — the same as the full walk.
17
+ * Nodes are checked by the generic functions below, which read the type tree and metadata
18
+ * LIVE on every visit. Array items — the same type visited many times per call — go
19
+ * through a compiled {@link Plan} of the item type instead (cached per node, shared by every
20
+ * validator and option set). A plan snapshots what its node's check reads and re-verifies
21
+ * every snapshot against the live node lazily, once per call, right before first using it
22
+ * (rebuilding it when anything differs); constraint objects and pattern arrays are read
23
+ * live on every visit. Either way `annotate()` / `metadata.set()` / prop mutations made
24
+ * after a validator was created are always honoured — the same as the full walk.
10
25
  *
11
26
  * Result contract (relative to the full walk over the same node and value):
12
27
  * - `PASS` — the walk returns `true`, collects no errors and has no side effects.
@@ -22,10 +37,12 @@ const PASS = 1;
22
37
  const BAIL = 2;
23
38
  /** Node is at walk depth 0 (only object props / array & tuple items increase depth). */ const TOP = 1;
24
39
  /** Node is inside a union branch — failures must be exhaustive (see contract). */ const IN_UNION = 2;
40
+ /** Incremented per {@link fastCheckPasses} call; snapshots verified in older calls re-verify. */ let stamp = 0;
25
41
  /**
26
42
  * `true` only when the full walk over `value` is guaranteed to pass with no errors
27
43
  * and no side effects. Any other outcome (including a throw) means "run the walk".
28
44
  */ function fastCheckPasses(def, value, opts) {
45
+ stamp++;
29
46
  try {
30
47
  return fastCheck(def, value, TOP, opts) === PASS;
31
48
  } catch {
@@ -76,7 +93,7 @@ function fastCheck(def, value, flags, opts) {
76
93
  const branchFlags = flags | IN_UNION;
77
94
  for (const item of type.items) {
78
95
  const result = fastCheck(item, value, branchFlags, opts);
79
- if (result !== FAIL) return result === PASS && item.type.value === void 0 ? fastCheckUnionConstraints(def.metadata, value) : result;
96
+ if (result !== FAIL) return unionMatchResult(result, item, def.metadata, value);
80
97
  }
81
98
  return FAIL;
82
99
  }
@@ -116,6 +133,9 @@ function fastCheckFinal(def, value) {
116
133
  default: return BAIL;
117
134
  }
118
135
  }
136
+ /** Result of a union whose branch `item` did not fail (`PASS` or `BAIL`). */ function unionMatchResult(result, item, metadata, value) {
137
+ return result === PASS && item.type.value === void 0 ? fastCheckUnionConstraints(metadata, value) : result;
138
+ }
119
139
  /**
120
140
  * Mirrors Validator.validateUnionConstraints: union-level constraints on the matched value
121
141
  * (`null` / objects pass; the caller skips literal branches).
@@ -130,8 +150,7 @@ function fastCheckFinal(def, value) {
130
150
  }
131
151
  }
132
152
  function fastCheckBoolean(metadata, value) {
133
- if (metadata.size === 0) return PASS;
134
- return metadata.get("meta.required") && value !== true ? FAIL : PASS;
153
+ return metadata.size === 0 ? PASS : booleanConstraints(value, metadata.get("meta.required"));
135
154
  }
136
155
  function fastCheckString(metadata, value) {
137
156
  if (metadata.size === 0) return PASS;
@@ -151,13 +170,24 @@ function fastCheckString(metadata, value) {
151
170
  }
152
171
  function fastCheckNumber(metadata, value) {
153
172
  if (metadata.size === 0) return PASS;
154
- if (metadata.get("expect.int") && value % 1 !== 0) return FAIL;
155
- const min = metadata.get("expect.min");
173
+ return numberConstraints(value, metadata.get("expect.int"), metadata.get("expect.min"), metadata.get("expect.max"));
174
+ }
175
+ function booleanConstraints(value, required) {
176
+ return required && value !== true ? FAIL : PASS;
177
+ }
178
+ function numberConstraints(value, int, min, max) {
179
+ if (int && value % 1 !== 0) return FAIL;
156
180
  if (min !== void 0 && value < (typeof min === "number" ? min : min.minValue)) return FAIL;
157
- const max = metadata.get("expect.max");
158
181
  if (max !== void 0 && value > (typeof max === "number" ? max : max.maxValue)) return FAIL;
159
182
  return PASS;
160
183
  }
184
+ /** `@expect.minLength` / `@expect.maxLength` (strings and arrays). */ function lengthFails(length, minLength, maxLength) {
185
+ return minLength !== void 0 && length < (typeof minLength === "number" ? minLength : minLength.length) || maxLength !== void 0 && length > (typeof maxLength === "number" ? maxLength : maxLength.length);
186
+ }
187
+ /** Array constraints; duplicate detection (`uniqueItems`) is left to the walk. */ function arrayConstraints(length, minLength, maxLength, uniqueItems) {
188
+ if (lengthFails(length, minLength, maxLength)) return FAIL;
189
+ return uniqueItems ? BAIL : PASS;
190
+ }
161
191
  function fastCheckObject(def, value, flags, opts) {
162
192
  if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
163
193
  const type = def.type;
@@ -195,12 +225,14 @@ function fastCheckArray(def, value, flags, opts) {
195
225
  const result = fastCheckArrayConstraints(metadata, value);
196
226
  if (result !== PASS) return result;
197
227
  }
198
- const of = def.type.of;
228
+ return checkItems(planFor(def.type.of), value, flags, opts);
229
+ }
230
+ /** Checks every array item against the item type's plan. */ function checkItems(of, value, flags, opts) {
199
231
  const inUnion = (flags & IN_UNION) !== 0;
200
232
  const itemFlags = flags & IN_UNION;
201
233
  let result = PASS;
202
234
  for (const item of value) {
203
- const itemResult = fastCheck(of, item, itemFlags, opts);
235
+ const itemResult = checkPlan(of, item, itemFlags, opts);
204
236
  if (itemResult !== PASS) {
205
237
  if (itemResult === BAIL || !inUnion) return itemResult;
206
238
  result = FAIL;
@@ -209,11 +241,338 @@ function fastCheckArray(def, value, flags, opts) {
209
241
  return result;
210
242
  }
211
243
  function fastCheckArrayConstraints(metadata, value) {
212
- const minLength = metadata.get("expect.minLength");
213
- if (minLength !== void 0 && value.length < (typeof minLength === "number" ? minLength : minLength.length)) return FAIL;
214
- const maxLength = metadata.get("expect.maxLength");
215
- if (maxLength !== void 0 && value.length > (typeof maxLength === "number" ? maxLength : maxLength.length)) return FAIL;
216
- return metadata.get("expect.array.uniqueItems") ? BAIL : PASS;
244
+ return arrayConstraints(value.length, metadata.get("expect.minLength"), metadata.get("expect.maxLength"), metadata.get("expect.array.uniqueItems"));
245
+ }
246
+ const OP_GENERIC = 0;
247
+ const OP_PHANTOM = 1;
248
+ const OP_STRING = 2;
249
+ const OP_NUMBER = 3;
250
+ const OP_BOOLEAN = 4;
251
+ /** Any other final node: checked by {@link fastCheckFinal}. */ const OP_FINAL = 5;
252
+ const OP_OBJECT = 6;
253
+ const OP_ARRAY = 7;
254
+ const OP_UNION = 8;
255
+ function isFinalOp(op) {
256
+ return op !== OP_GENERIC && op <= OP_FINAL;
257
+ }
258
+ /** Shared placeholder for the per-kind arrays of plans that don't use them. */ const EMPTY = Object.freeze([]);
259
+ const plans = /* @__PURE__ */ new WeakMap();
260
+ /** One shape for every plan, so plan field access stays monomorphic. */ let Plan = class Plan {
261
+ constructor(def) {
262
+ _define_property$1(this, "def", void 0);
263
+ /** Call in which the node structure was last verified (`-1`: must rebuild). */ _define_property$1(this, "stamp", void 0);
264
+ /** Call in which the annotation values (`m0`–`m3`) were last verified. */ _define_property$1(this, "metaStamp", void 0);
265
+ _define_property$1(this, "op", void 0);
266
+ _define_property$1(this, "type", void 0);
267
+ _define_property$1(this, "optional", void 0);
268
+ _define_property$1(this, "metadata", void 0);
269
+ _define_property$1(this, "kind", void 0);
270
+ _define_property$1(this, "designType", void 0);
271
+ _define_property$1(this, "literal", void 0);
272
+ /** String plans: compiled `@expect.pattern` regexes by position (checked against the live entry). */ _define_property$1(this, "regexes", void 0);
273
+ /**
274
+ * Annotation keys the node's check reads, and their values (`undefined` when absent):
275
+ * string `meta.required, expect.minLength, maxLength, pattern`; number `expect.int, min,
276
+ * max`; boolean `meta.required`; array `expect.minLength, maxLength, array.uniqueItems`.
277
+ */ _define_property$1(this, "k0", void 0);
278
+ _define_property$1(this, "k1", void 0);
279
+ _define_property$1(this, "k2", void 0);
280
+ _define_property$1(this, "k3", void 0);
281
+ _define_property$1(this, "m0", void 0);
282
+ _define_property$1(this, "m1", void 0);
283
+ _define_property$1(this, "m2", void 0);
284
+ _define_property$1(this, "m3", void 0);
285
+ _define_property$1(this, "props", void 0);
286
+ _define_property$1(this, "propsPatterns", void 0);
287
+ _define_property$1(this, "keys", void 0);
288
+ /** Call in which `props.get(keys[i]) === nodes[i]` was last verified. */ _define_property$1(this, "edges", void 0);
289
+ /** Prop plans by key (the entries of `props`, verified per visit via `edges`). */ _define_property$1(this, "byKey", void 0);
290
+ _define_property$1(this, "nodes", void 0);
291
+ _define_property$1(this, "children", void 0);
292
+ _define_property$1(this, "of", void 0);
293
+ _define_property$1(this, "ofPlan", void 0);
294
+ _define_property$1(this, "items", void 0);
295
+ this.def = def;
296
+ this.stamp = -1;
297
+ this.metaStamp = -1;
298
+ this.op = OP_GENERIC;
299
+ this.type = void 0;
300
+ this.optional = void 0;
301
+ this.metadata = void 0;
302
+ this.kind = void 0;
303
+ this.designType = void 0;
304
+ this.literal = void 0;
305
+ this.regexes = EMPTY;
306
+ this.k0 = void 0;
307
+ this.k1 = void 0;
308
+ this.k2 = void 0;
309
+ this.k3 = void 0;
310
+ this.m0 = void 0;
311
+ this.m1 = void 0;
312
+ this.m2 = void 0;
313
+ this.m3 = void 0;
314
+ this.props = void 0;
315
+ this.propsPatterns = void 0;
316
+ this.keys = EMPTY;
317
+ this.edges = EMPTY;
318
+ this.byKey = void 0;
319
+ this.nodes = EMPTY;
320
+ this.children = EMPTY;
321
+ this.of = void 0;
322
+ this.ofPlan = void 0;
323
+ this.items = void 0;
324
+ }
325
+ };
326
+ function planFor(def) {
327
+ let plan = plans.get(def);
328
+ if (plan === void 0) {
329
+ plan = new Plan(def);
330
+ plans.set(def, plan);
331
+ }
332
+ return plan;
333
+ }
334
+ /** Brings the plan's structure up to date with its live node (once per call). */ function refresh(plan) {
335
+ if (!(isFinalOp(plan.op) ? verifyFinal(plan) : verify(plan))) build(plan);
336
+ plan.stamp = stamp;
337
+ }
338
+ /** Structure check for final ops; small enough to be inlined into the hot loops. */ function verifyFinal(plan) {
339
+ const def = plan.def;
340
+ const type = def.type;
341
+ return plan.stamp !== -1 && type === plan.type && def.optional === plan.optional && def.metadata === plan.metadata && type.kind === "" && type.designType === plan.designType && type.value === plan.literal;
342
+ }
343
+ /** Structure check for objects, arrays, unions and generic nodes. */ function verify(plan) {
344
+ if (plan.stamp === -1) return false;
345
+ const def = plan.def;
346
+ const type = def.type;
347
+ if (type !== plan.type || def.optional !== plan.optional || def.metadata !== plan.metadata || type.kind !== plan.kind) return false;
348
+ switch (plan.op) {
349
+ case OP_OBJECT: return type.props === plan.props && plan.props.size === plan.keys.length && type.propsPatterns === plan.propsPatterns && plan.propsPatterns.length === 0;
350
+ case OP_ARRAY: return type.of === plan.of;
351
+ case OP_UNION: {
352
+ const items = plan.items;
353
+ const nodes = plan.nodes;
354
+ if (type.items !== items || items.length !== nodes.length) return false;
355
+ for (let i = 0; i < nodes.length; i++) if (items[i] !== nodes[i]) return false;
356
+ return true;
357
+ }
358
+ default: return type.kind !== "object" || type.propsPatterns.length > 0;
359
+ }
360
+ }
361
+ /** Brings the annotation values up to date (once per call, when a constraint is read). */ function refreshMeta(plan) {
362
+ const metadata = plan.metadata;
363
+ if (!(metadata.size === 0 ? plan.m0 === void 0 && plan.m1 === void 0 && plan.m2 === void 0 && plan.m3 === void 0 : metadata.get(plan.k0) === plan.m0 && (plan.k1 === void 0 || metadata.get(plan.k1) === plan.m1) && (plan.k2 === void 0 || metadata.get(plan.k2) === plan.m2) && (plan.k3 === void 0 || metadata.get(plan.k3) === plan.m3))) snapshotMeta(plan);
364
+ plan.metaStamp = stamp;
365
+ }
366
+ function snapshotMeta(plan) {
367
+ const metadata = plan.metadata;
368
+ plan.m0 = metadata.get(plan.k0);
369
+ plan.m1 = metadata.get(plan.k1);
370
+ plan.m2 = metadata.get(plan.k2);
371
+ plan.m3 = metadata.get(plan.k3);
372
+ }
373
+ function setMetaKeys(plan, k0, k1, k2, k3) {
374
+ plan.k0 = k0;
375
+ plan.k1 = k1;
376
+ plan.k2 = k2;
377
+ plan.k3 = k3;
378
+ snapshotMeta(plan);
379
+ plan.metaStamp = stamp;
380
+ }
381
+ /** (Re)compiles `plan` from its live node. */ function build(plan) {
382
+ plan.stamp = -1;
383
+ plan.op = OP_GENERIC;
384
+ const def = plan.def;
385
+ const type = def.type;
386
+ plan.type = type;
387
+ plan.optional = def.optional;
388
+ plan.metadata = def.metadata;
389
+ plan.kind = type.kind;
390
+ plan.designType = type.designType;
391
+ plan.literal = type.value;
392
+ plan.regexes = EMPTY;
393
+ plan.props = void 0;
394
+ plan.propsPatterns = void 0;
395
+ plan.keys = EMPTY;
396
+ plan.edges = EMPTY;
397
+ plan.byKey = void 0;
398
+ plan.nodes = EMPTY;
399
+ plan.children = EMPTY;
400
+ plan.of = void 0;
401
+ plan.ofPlan = void 0;
402
+ plan.items = void 0;
403
+ setMetaKeys(plan, void 0, void 0, void 0, void 0);
404
+ switch (type.kind) {
405
+ case "":
406
+ if (type.designType === "phantom") plan.op = OP_PHANTOM;
407
+ else if (type.value !== void 0) plan.op = OP_FINAL;
408
+ else if (type.designType === "string") {
409
+ setMetaKeys(plan, "meta.required", "expect.minLength", "expect.maxLength", "expect.pattern");
410
+ plan.regexes = [];
411
+ plan.op = OP_STRING;
412
+ } else if (type.designType === "number") {
413
+ setMetaKeys(plan, "expect.int", "expect.min", "expect.max", void 0);
414
+ plan.op = OP_NUMBER;
415
+ } else if (type.designType === "boolean") {
416
+ setMetaKeys(plan, "meta.required", void 0, void 0, void 0);
417
+ plan.op = OP_BOOLEAN;
418
+ } else plan.op = OP_FINAL;
419
+ break;
420
+ case "object": {
421
+ if (type.propsPatterns.length > 0) break;
422
+ const byKey = /* @__PURE__ */ new Map();
423
+ plan.keys = [];
424
+ plan.edges = [];
425
+ plan.nodes = [];
426
+ plan.children = [];
427
+ for (const [key, node] of type.props) {
428
+ const child = planFor(node);
429
+ plan.keys.push(key);
430
+ plan.edges.push(stamp);
431
+ plan.nodes.push(node);
432
+ plan.children.push(child);
433
+ byKey.set(key, child);
434
+ }
435
+ plan.byKey = byKey;
436
+ plan.props = type.props;
437
+ plan.propsPatterns = type.propsPatterns;
438
+ plan.op = OP_OBJECT;
439
+ break;
440
+ }
441
+ case "array":
442
+ setMetaKeys(plan, "expect.minLength", "expect.maxLength", "expect.array.uniqueItems", void 0);
443
+ plan.of = type.of;
444
+ plan.ofPlan = planFor(type.of);
445
+ plan.op = OP_ARRAY;
446
+ break;
447
+ case "union":
448
+ plan.nodes = [];
449
+ plan.children = [];
450
+ for (const node of type.items) {
451
+ plan.nodes.push(node);
452
+ plan.children.push(planFor(node));
453
+ }
454
+ plan.items = type.items;
455
+ plan.op = OP_UNION;
456
+ break;
457
+ default:
458
+ }
459
+ }
460
+ /** Plan counterpart of {@link fastCheck}. */ function checkPlan(plan, value, flags, opts) {
461
+ if (plan.stamp !== stamp) refresh(plan);
462
+ if (plan.optional && (value === void 0 || value === null)) return value === null && rejectsNullAsRequired(plan.def) ? FAIL : PASS;
463
+ switch (plan.op) {
464
+ case OP_STRING: return typeof value === "string" ? checkString(plan, value) : FAIL;
465
+ case OP_NUMBER: return typeof value === "number" && Number.isFinite(value) ? checkNumber(plan, value) : FAIL;
466
+ case OP_OBJECT: return checkObject(plan, value, flags, opts);
467
+ case OP_ARRAY: return checkArray(plan, value, flags, opts);
468
+ case OP_UNION: {
469
+ const branchFlags = flags | IN_UNION;
470
+ for (const child of plan.children) {
471
+ const result = checkPlan(child, value, branchFlags, opts);
472
+ if (result !== FAIL) return unionMatchResult(result, child.def, plan.metadata, value);
473
+ }
474
+ return FAIL;
475
+ }
476
+ case OP_BOOLEAN:
477
+ if (typeof value !== "boolean") return FAIL;
478
+ if (plan.metaStamp !== stamp) refreshMeta(plan);
479
+ return booleanConstraints(value, plan.m0);
480
+ case OP_PHANTOM:
481
+ case OP_FINAL: return fastCheckFinal(plan.def, value);
482
+ default: return fastCheck(plan.def, value, flags, opts);
483
+ }
484
+ }
485
+ /** Plan counterpart of {@link fastCheckString}; constraint objects are read live. */ function checkString(plan, value) {
486
+ if (plan.metaStamp !== stamp) refreshMeta(plan);
487
+ if (plan.m0 && value.trim().length === 0) return FAIL;
488
+ if (lengthFails(value.length, plan.m1, plan.m2)) return FAIL;
489
+ const patterns = plan.m3;
490
+ if (patterns) {
491
+ if (!Array.isArray(patterns)) return fastCheckString(plan.metadata, value);
492
+ for (let i = 0; i < patterns.length; i++) {
493
+ const { pattern, flags } = patterns[i];
494
+ if (!pattern) continue;
495
+ let entry = plan.regexes[i];
496
+ if (entry === void 0 || entry.pattern !== pattern || entry.flags !== flags) {
497
+ const re = getRegex(pattern, flags);
498
+ entry = {
499
+ pattern,
500
+ flags,
501
+ re,
502
+ stateful: re.global || re.sticky
503
+ };
504
+ plan.regexes[i] = entry;
505
+ }
506
+ if (entry.stateful) return BAIL;
507
+ if (!entry.re.test(value)) return FAIL;
508
+ }
509
+ }
510
+ return PASS;
511
+ }
512
+ /** Plan counterpart of {@link fastCheckNumber}; constraint objects are read live. */ function checkNumber(plan, value) {
513
+ if (plan.metaStamp !== stamp) refreshMeta(plan);
514
+ return numberConstraints(value, plan.m0, plan.m1, plan.m2);
515
+ }
516
+ /** Plan counterpart of {@link fastCheckObject}. */ function checkObject(plan, value, flags, opts) {
517
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return FAIL;
518
+ const partial = opts.partial;
519
+ const skipUndefined = partial === "deep" || partial === true && (flags & TOP) !== 0;
520
+ const inUnion = (flags & IN_UNION) !== 0;
521
+ const propFlags = flags & IN_UNION;
522
+ const keys = plan.keys;
523
+ const children = plan.children;
524
+ const edges = plan.edges;
525
+ let result = PASS;
526
+ for (let i = 0; i < keys.length; i++) {
527
+ if (edges[i] !== stamp) {
528
+ if (plan.props.get(keys[i]) !== plan.nodes[i]) {
529
+ plan.stamp = -1;
530
+ return BAIL;
531
+ }
532
+ edges[i] = stamp;
533
+ }
534
+ const child = children[i];
535
+ if (child.stamp !== stamp) refresh(child);
536
+ const op = child.op;
537
+ if (op === OP_PHANTOM) continue;
538
+ const propValue = value[keys[i]];
539
+ if (propValue === void 0 && skipUndefined) continue;
540
+ if (typeof propValue === "string" && op === OP_STRING) {
541
+ const r = checkString(child, propValue);
542
+ if (r === PASS) continue;
543
+ if (r === BAIL || !inUnion) return r;
544
+ result = FAIL;
545
+ continue;
546
+ }
547
+ if (typeof propValue === "number" && op === OP_NUMBER) {
548
+ if (Number.isFinite(propValue) && checkNumber(child, propValue) === PASS) continue;
549
+ if (!inUnion) return FAIL;
550
+ result = FAIL;
551
+ continue;
552
+ }
553
+ const propResult = checkPlan(child, propValue, propFlags, opts);
554
+ if (propResult !== PASS) {
555
+ if (propResult === BAIL || !inUnion) return propResult;
556
+ result = FAIL;
557
+ }
558
+ }
559
+ if (result !== PASS) return result;
560
+ const unknownProps = opts.unknownProps;
561
+ if (unknownProps === "error" || unknownProps === "strip") {
562
+ const byKey = plan.byKey;
563
+ for (const key of Object.keys(value)) {
564
+ const known = byKey.get(key);
565
+ if (known === void 0 || known.op === OP_PHANTOM) return unknownProps === "error" ? FAIL : BAIL;
566
+ }
567
+ }
568
+ return PASS;
569
+ }
570
+ /** Plan counterpart of {@link fastCheckArray}. */ function checkArray(plan, value, flags, opts) {
571
+ if (!Array.isArray(value)) return FAIL;
572
+ if (plan.metaStamp !== stamp) refreshMeta(plan);
573
+ const result = arrayConstraints(value.length, plan.m0, plan.m1, plan.m2);
574
+ if (result !== PASS) return result;
575
+ return checkItems(plan.ofPlan, value, flags, opts);
217
576
  }
218
577
 
219
578
  //#endregion
@@ -564,7 +923,7 @@ function _define_property(obj, key, value) {
564
923
  validatePrimitive(def, value) {
565
924
  if (def.type.value !== void 0) {
566
925
  if (value !== def.type.value) {
567
- this.error(`Expected ${def.type.value}, got ${value}`);
926
+ this.error(`Expected ${def.type.value}, got ${printValue(value)}`);
568
927
  return false;
569
928
  }
570
929
  return true;
@@ -756,6 +1115,13 @@ function _define_property(obj, key, value) {
756
1115
  if (of) return of;
757
1116
  }
758
1117
  }
1118
+ /** `${value}` throws for symbols and null-prototype objects: `String()` handles symbols, the tag the rest. */ function printValue(value) {
1119
+ try {
1120
+ return String(value);
1121
+ } catch {
1122
+ return Object.prototype.toString.call(value);
1123
+ }
1124
+ }
759
1125
  /** Error thrown by {@link Validator.validate} when validation fails. Contains structured error details. */ var ValidatorError = class extends Error {
760
1126
  constructor(errors) {
761
1127
  super(`${errors[0].path ? errors[0].path + ": " : ""}${errors[0].message}`), _define_property(this, "errors", void 0), _define_property(this, "name", void 0), this.errors = errors, this.name = "Validation Error";