@oxog/vld 2.1.0 → 2.2.7
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.
- package/CHANGELOG.md +113 -0
- package/README.md +413 -1235
- package/dist/chunks/errors-core-CerMg2rq.js +1 -0
- package/dist/chunks/index-CkbfQQ4n.js +1 -0
- package/dist/chunks/index-yjpbvFgw.js +1 -0
- package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
- package/dist/chunks/security-Dy24T8N7.js +1 -0
- package/dist/cjs/chunks/errors-core-DrydF46s.cjs +1 -0
- package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
- package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
- package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
- package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
- package/dist/cjs/cli/bin.cjs +1 -505
- package/dist/cjs/cli/index.cjs +1 -209
- package/dist/cjs/codecs/index.cjs +1 -45
- package/dist/cjs/coercion/index.cjs +1 -588
- package/dist/cjs/compat/emitter.cjs +1 -184
- package/dist/cjs/compat/result.cjs +1 -189
- package/dist/cjs/errors.cjs +1 -180
- package/dist/cjs/index.cjs +1 -1894
- package/dist/cjs/kernel.cjs +1 -415
- package/dist/cjs/locales/af.cjs +1 -108
- package/dist/cjs/locales/ar.cjs +1 -108
- package/dist/cjs/locales/bn.cjs +1 -108
- package/dist/cjs/locales/da.cjs +1 -108
- package/dist/cjs/locales/de.cjs +1 -108
- package/dist/cjs/locales/en.cjs +1 -108
- package/dist/cjs/locales/es-MX.cjs +1 -107
- package/dist/cjs/locales/es.cjs +1 -96
- package/dist/cjs/locales/fi.cjs +1 -108
- package/dist/cjs/locales/fr.cjs +1 -96
- package/dist/cjs/locales/hi.cjs +1 -108
- package/dist/cjs/locales/id.cjs +1 -108
- package/dist/cjs/locales/index.cjs +1 -43
- package/dist/cjs/locales/it.cjs +1 -108
- package/dist/cjs/locales/ja.cjs +1 -108
- package/dist/cjs/locales/ko.cjs +1 -108
- package/dist/cjs/locales/lazy.cjs +1 -188
- package/dist/cjs/locales/nl.cjs +1 -108
- package/dist/cjs/locales/no.cjs +1 -108
- package/dist/cjs/locales/pl.cjs +1 -108
- package/dist/cjs/locales/pt-BR.cjs +1 -108
- package/dist/cjs/locales/pt.cjs +1 -108
- package/dist/cjs/locales/ru.cjs +1 -108
- package/dist/cjs/locales/runtime.cjs +1 -51
- package/dist/cjs/locales/sv.cjs +1 -108
- package/dist/cjs/locales/sw.cjs +1 -108
- package/dist/cjs/locales/th.cjs +1 -108
- package/dist/cjs/locales/tr.cjs +1 -108
- package/dist/cjs/locales/vi.cjs +1 -108
- package/dist/cjs/locales/zh.cjs +1 -108
- package/dist/cjs/mini.cjs +1 -242
- package/dist/cjs/pigment.cjs +1 -207
- package/dist/cjs/plugins/index.cjs +1 -12
- package/dist/cjs/registry.cjs +1 -37
- package/dist/cjs/v3/index.cjs +1 -425
- package/dist/cjs/v4/core/index.cjs +1 -894
- package/dist/cjs/v4/index.cjs +1 -425
- package/dist/cjs/v4/locales/index.cjs +1 -130
- package/dist/cjs/v4/mini/index.cjs +1 -509
- package/dist/cjs/v4-mini/index.cjs +1 -532
- package/dist/cjs/validators/any.cjs +1 -40
- package/dist/cjs/validators/array.cjs +1 -283
- package/dist/cjs/validators/base.cjs +1 -887
- package/dist/cjs/validators/base64.cjs +1 -73
- package/dist/cjs/validators/bigint.cjs +1 -232
- package/dist/cjs/validators/boolean.cjs +1 -146
- package/dist/cjs/validators/codec.cjs +1 -205
- package/dist/cjs/validators/custom.cjs +1 -71
- package/dist/cjs/validators/date.cjs +1 -278
- package/dist/cjs/validators/discriminated-union.cjs +1 -130
- package/dist/cjs/validators/enum.cjs +1 -154
- package/dist/cjs/validators/file.cjs +1 -130
- package/dist/cjs/validators/function.cjs +1 -63
- package/dist/cjs/validators/hex.cjs +1 -70
- package/dist/cjs/validators/index.cjs +1 -123
- package/dist/cjs/validators/intersection.cjs +1 -120
- package/dist/cjs/validators/json.cjs +1 -70
- package/dist/cjs/validators/lazy.cjs +1 -53
- package/dist/cjs/validators/literal.cjs +1 -64
- package/dist/cjs/validators/map.cjs +1 -218
- package/dist/cjs/validators/nan.cjs +1 -41
- package/dist/cjs/validators/never.cjs +1 -36
- package/dist/cjs/validators/null.cjs +1 -43
- package/dist/cjs/validators/number.cjs +1 -427
- package/dist/cjs/validators/object.cjs +1 -868
- package/dist/cjs/validators/promise.cjs +1 -115
- package/dist/cjs/validators/record.cjs +1 -262
- package/dist/cjs/validators/set.cjs +1 -203
- package/dist/cjs/validators/string-bool.cjs +1 -124
- package/dist/cjs/validators/string-formats.cjs +1 -168
- package/dist/cjs/validators/string.cjs +1 -12
- package/dist/cjs/validators/symbol.cjs +1 -62
- package/dist/cjs/validators/template-literal.cjs +1 -108
- package/dist/cjs/validators/tuple.cjs +1 -187
- package/dist/cjs/validators/uint8array.cjs +1 -106
- package/dist/cjs/validators/undefined.cjs +1 -43
- package/dist/cjs/validators/union.cjs +1 -191
- package/dist/cjs/validators/unknown.cjs +1 -40
- package/dist/cjs/validators/void.cjs +1 -48
- package/dist/cjs/validators/xor.cjs +1 -69
- package/dist/cli/bin.js +1 -406
- package/dist/cli/index.js +1 -205
- package/dist/codecs/index.js +1 -11
- package/dist/coercion/index.js +1 -579
- package/dist/compat/emitter.js +1 -180
- package/dist/compat/result.js +1 -170
- package/dist/errors-core.d.ts +32 -2
- package/dist/errors.js +1 -171
- package/dist/index.d.ts +315 -361
- package/dist/index.js +1 -1534
- package/dist/kernel.js +1 -409
- package/dist/locales/af.js +1 -106
- package/dist/locales/ar.js +1 -106
- package/dist/locales/bn.js +1 -106
- package/dist/locales/da.js +1 -106
- package/dist/locales/de.js +1 -106
- package/dist/locales/en.js +1 -106
- package/dist/locales/es-MX.js +1 -105
- package/dist/locales/es.js +1 -94
- package/dist/locales/fi.js +1 -106
- package/dist/locales/fr.js +1 -94
- package/dist/locales/hi.js +1 -106
- package/dist/locales/id.js +1 -106
- package/dist/locales/index.js +1 -29
- package/dist/locales/it.js +1 -106
- package/dist/locales/ja.js +1 -106
- package/dist/locales/ko.js +1 -106
- package/dist/locales/lazy.js +1 -177
- package/dist/locales/nl.js +1 -106
- package/dist/locales/no.js +1 -106
- package/dist/locales/pl.js +1 -106
- package/dist/locales/pt-BR.js +1 -106
- package/dist/locales/pt.js +1 -106
- package/dist/locales/ru.js +1 -106
- package/dist/locales/runtime.js +1 -41
- package/dist/locales/sv.js +1 -106
- package/dist/locales/sw.js +1 -106
- package/dist/locales/th.js +1 -106
- package/dist/locales/tr.js +1 -106
- package/dist/locales/vi.js +1 -106
- package/dist/locales/zh.js +1 -106
- package/dist/mini.d.ts +3 -3
- package/dist/mini.js +1 -156
- package/dist/pigment.js +1 -180
- package/dist/plugins/index.js +1 -1
- package/dist/registry.js +1 -34
- package/dist/utils/json-schema.d.ts +10 -1
- package/dist/v3/index.js +1 -46
- package/dist/v4/core/index.d.ts +28 -16
- package/dist/v4/core/index.js +1 -277
- package/dist/v4/index.js +1 -50
- package/dist/v4/locales/index.d.ts +4 -0
- package/dist/v4/locales/index.js +1 -77
- package/dist/v4/mini/index.js +1 -47
- package/dist/v4-mini/index.d.ts +1 -1
- package/dist/v4-mini/index.js +1 -75
- package/dist/validators/any.js +1 -37
- package/dist/validators/array.d.ts +7 -0
- package/dist/validators/array.js +1 -279
- package/dist/validators/base.d.ts +210 -17
- package/dist/validators/base.js +1 -868
- package/dist/validators/base64.js +1 -68
- package/dist/validators/bigint.d.ts +7 -0
- package/dist/validators/bigint.js +1 -228
- package/dist/validators/boolean.js +1 -142
- package/dist/validators/codec.js +1 -200
- package/dist/validators/custom.d.ts +20 -10
- package/dist/validators/custom.js +1 -67
- package/dist/validators/date.d.ts +2 -0
- package/dist/validators/date.js +1 -274
- package/dist/validators/discriminated-union.d.ts +4 -2
- package/dist/validators/discriminated-union.js +1 -123
- package/dist/validators/enum.d.ts +8 -2
- package/dist/validators/enum.js +1 -150
- package/dist/validators/file.js +1 -125
- package/dist/validators/function.js +1 -58
- package/dist/validators/hex.js +1 -65
- package/dist/validators/index.d.ts +1 -1
- package/dist/validators/index.js +1 -35
- package/dist/validators/intersection.js +1 -116
- package/dist/validators/json.js +1 -66
- package/dist/validators/lazy.js +1 -50
- package/dist/validators/literal.d.ts +8 -3
- package/dist/validators/literal.js +1 -60
- package/dist/validators/map.d.ts +7 -0
- package/dist/validators/map.js +1 -214
- package/dist/validators/nan.js +1 -38
- package/dist/validators/never.js +1 -32
- package/dist/validators/null.js +1 -40
- package/dist/validators/number.d.ts +25 -1
- package/dist/validators/number.js +1 -423
- package/dist/validators/object.d.ts +18 -2
- package/dist/validators/object.js +1 -864
- package/dist/validators/promise.d.ts +6 -7
- package/dist/validators/promise.js +1 -111
- package/dist/validators/record.d.ts +13 -8
- package/dist/validators/record.js +1 -258
- package/dist/validators/set.d.ts +5 -0
- package/dist/validators/set.js +1 -199
- package/dist/validators/string-bool.js +1 -120
- package/dist/validators/string-formats.d.ts +58 -62
- package/dist/validators/string-formats.js +1 -135
- package/dist/validators/string.d.ts +49 -10
- package/dist/validators/string.js +1 -4
- package/dist/validators/symbol.js +1 -58
- package/dist/validators/template-literal.js +1 -103
- package/dist/validators/tuple.d.ts +17 -13
- package/dist/validators/tuple.js +1 -183
- package/dist/validators/uint8array.js +1 -101
- package/dist/validators/undefined.js +1 -40
- package/dist/validators/union.d.ts +1 -0
- package/dist/validators/union.js +1 -187
- package/dist/validators/unknown.js +1 -37
- package/dist/validators/void.js +1 -44
- package/dist/validators/xor.d.ts +2 -2
- package/dist/validators/xor.js +1 -66
- package/package.json +240 -238
- package/dist/chunks/errors-core-BeiFUtZM.js +0 -81
- package/dist/chunks/index-0R2ntSud.js +0 -508
- package/dist/chunks/index-BvH403Yy.js +0 -88
- package/dist/chunks/security-B0Pd_vSY.js +0 -35
- package/dist/chunks/string-BJRQod3t.js +0 -530
- package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +0 -83
- package/dist/cjs/chunks/index-BkI37108.cjs +0 -538
- package/dist/cjs/chunks/index-Cc3bjUMX.cjs +0 -91
- package/dist/cjs/chunks/security-Dc3Jh13T.cjs +0 -37
- package/dist/cjs/chunks/string-BKZrc4hs.cjs +0 -533
package/dist/validators/lazy.js
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* VldLazy - Lazy evaluation for recursive schemas
|
|
5
|
-
* Part of Zod 4 API parity implementation
|
|
6
|
-
* Allows schemas that reference themselves (e.g., tree structures, nested categories)
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Lazy validator - defers schema evaluation until runtime
|
|
10
|
-
* Essential for recursive and self-referencing types
|
|
11
|
-
*
|
|
12
|
-
* Caches the resolved schema after first use. This keeps recursive schemas stable
|
|
13
|
-
* and avoids re-running the schema getter on hot parse paths.
|
|
14
|
-
*/
|
|
15
|
-
class VldLazy extends VldBase {
|
|
16
|
-
constructor(_schemaGetter) {
|
|
17
|
-
super(VLD_VALIDATOR_TYPES.LAZY);
|
|
18
|
-
this._schemaGetter = _schemaGetter;
|
|
19
|
-
this._cachedSchema = null;
|
|
20
|
-
}
|
|
21
|
-
static create(schemaGetter) {
|
|
22
|
-
return new VldLazy(schemaGetter);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Get the actual schema, caching it after first retrieval
|
|
26
|
-
*/
|
|
27
|
-
_getSchema() {
|
|
28
|
-
if (this._cachedSchema) {
|
|
29
|
-
return this._cachedSchema;
|
|
30
|
-
}
|
|
31
|
-
const schema = this._schemaGetter();
|
|
32
|
-
this._cachedSchema = schema;
|
|
33
|
-
return schema;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Get the inner schema (unwrap)
|
|
37
|
-
* Returns a strong reference that will keep the schema alive
|
|
38
|
-
*/
|
|
39
|
-
unwrap() {
|
|
40
|
-
return this._getSchema();
|
|
41
|
-
}
|
|
42
|
-
parse(value) {
|
|
43
|
-
return this._getSchema().parse(value);
|
|
44
|
-
}
|
|
45
|
-
safeParse(value) {
|
|
46
|
-
return this._getSchema().safeParse(value);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export { VldLazy };
|
|
1
|
+
import{VldBase as e,VLD_VALIDATOR_TYPES as t}from"./base.js";class VldLazy extends e{constructor(e){super(t.LAZY),this._schemaGetter=e,this._cachedSchema=null}static create(e){return new VldLazy(e)}_getSchema(){if(this._cachedSchema)return this._cachedSchema;const e=this._schemaGetter();return this._cachedSchema=e,e}unwrap(){return this._getSchema()}parse(e){return this._getSchema().parse(e)}safeParse(e){return this._getSchema().safeParse(e)}}export{VldLazy};
|
|
@@ -2,8 +2,9 @@ import { VldBase, ParseResult } from './base.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Immutable literal validator for exact value matching
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
6
|
-
|
|
5
|
+
export type LiteralValue = string | number | bigint | boolean | null | undefined;
|
|
6
|
+
export declare class VldLiteral<T extends LiteralValue> extends VldBase<T, T> {
|
|
7
|
+
private readonly _values;
|
|
7
8
|
private readonly errorMessage?;
|
|
8
9
|
/**
|
|
9
10
|
* Private constructor to enforce immutability
|
|
@@ -13,15 +14,19 @@ export declare class VldLiteral<T extends string | number | boolean | null | und
|
|
|
13
14
|
* Get the literal value
|
|
14
15
|
*/
|
|
15
16
|
get literal(): T;
|
|
17
|
+
get value(): T;
|
|
18
|
+
get values(): readonly T[];
|
|
16
19
|
get isSimple(): boolean;
|
|
20
|
+
private get expectedDisplay();
|
|
17
21
|
/**
|
|
18
22
|
* Create a new literal validator
|
|
19
23
|
*/
|
|
20
|
-
static create<T extends
|
|
24
|
+
static create<T extends LiteralValue>(literal: T | readonly T[]): VldLiteral<T>;
|
|
21
25
|
/**
|
|
22
26
|
* Parse and validate a literal value
|
|
23
27
|
*/
|
|
24
28
|
parse(value: unknown): T;
|
|
29
|
+
private _createLiteralError;
|
|
25
30
|
/**
|
|
26
31
|
* Safely parse and validate a literal value
|
|
27
32
|
*/
|
|
@@ -1,60 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getMessages } from '../locales/runtime.js';
|
|
3
|
-
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
4
|
-
|
|
5
|
-
function createLiteralError(message) {
|
|
6
|
-
return new VldError([{ code: 'invalid_literal', path: [], message }]);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Immutable literal validator for exact value matching
|
|
10
|
-
*/
|
|
11
|
-
class VldLiteral extends VldBase {
|
|
12
|
-
/**
|
|
13
|
-
* Private constructor to enforce immutability
|
|
14
|
-
*/
|
|
15
|
-
constructor(_literal, errorMessage) {
|
|
16
|
-
super(VLD_VALIDATOR_TYPES.LITERAL);
|
|
17
|
-
this._literal = _literal;
|
|
18
|
-
this.errorMessage = errorMessage;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the literal value
|
|
22
|
-
*/
|
|
23
|
-
get literal() {
|
|
24
|
-
return this._literal;
|
|
25
|
-
}
|
|
26
|
-
get isSimple() {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Create a new literal validator
|
|
31
|
-
*/
|
|
32
|
-
static create(literal) {
|
|
33
|
-
return new VldLiteral(literal);
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parse and validate a literal value
|
|
37
|
-
*/
|
|
38
|
-
parse(value) {
|
|
39
|
-
if (value !== this._literal) {
|
|
40
|
-
throw new Error(this.errorMessage ||
|
|
41
|
-
getMessages().literalExpected(JSON.stringify(this._literal), JSON.stringify(value)));
|
|
42
|
-
}
|
|
43
|
-
return this._literal;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Safely parse and validate a literal value
|
|
47
|
-
*/
|
|
48
|
-
safeParse(value) {
|
|
49
|
-
if (value === this._literal) {
|
|
50
|
-
return { success: true, data: this._literal };
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
success: false,
|
|
54
|
-
error: createLiteralError(this.errorMessage ||
|
|
55
|
-
getMessages().literalExpected(JSON.stringify(this._literal), JSON.stringify(value)))
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { VldLiteral };
|
|
1
|
+
import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{getMessages as t}from"../locales/runtime.js";import{V as s}from"../chunks/errors-core-CerMg2rq.js";function a(e){const r=JSON.stringify(e,(e,r)=>"bigint"==typeof r?r.toString():r);return void 0===r?String(e):r}class VldLiteral extends e{constructor(e,t){super(r.LITERAL),this._values=e,this.errorMessage=t}get literal(){return this._values[0]}get value(){return this._values[0]}get values(){return this._values}get isSimple(){return 1===this._values.length}get expectedDisplay(){return a(1===this._values.length?this._values[0]:this._values)}static create(e){const r=Array.isArray(e)?e:[e];if(0===r.length)throw new Error("Cannot create literal schema with no valid values");return new VldLiteral(r)}parse(e){if(!this._values.includes(e))throw this._createLiteralError(e);return e}_createLiteralError(e){const r={code:"invalid_value",path:[],values:[...this._values],message:this.errorMessage||t().literalExpected(this.expectedDisplay,a(e))};return new s([r])}safeParse(e){return this._values.includes(e)?{success:!0,data:e}:{success:!1,error:this._createLiteralError(e)}}}export{VldLiteral};
|
package/dist/validators/map.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare class VldMap<K, V> extends VldBase<unknown, Map<K, V>> {
|
|
|
6
6
|
private readonly keyValidator;
|
|
7
7
|
private readonly valueValidator;
|
|
8
8
|
private readonly errorMessage?;
|
|
9
|
+
private readonly _checks;
|
|
9
10
|
/**
|
|
10
11
|
* Private constructor to enforce immutability
|
|
11
12
|
*/
|
|
@@ -16,6 +17,8 @@ export declare class VldMap<K, V> extends VldBase<unknown, Map<K, V>> {
|
|
|
16
17
|
private readonly _simpleValueValue;
|
|
17
18
|
get keySchema(): VldBase<unknown, K>;
|
|
18
19
|
get valueSchema(): VldBase<unknown, V>;
|
|
20
|
+
get keyType(): VldBase<unknown, K>;
|
|
21
|
+
get valueType(): VldBase<unknown, V>;
|
|
19
22
|
/**
|
|
20
23
|
* Create a new Map validator
|
|
21
24
|
*/
|
|
@@ -36,4 +39,8 @@ export declare class VldMap<K, V> extends VldBase<unknown, Map<K, V>> {
|
|
|
36
39
|
* Safely parse and validate a Map value
|
|
37
40
|
*/
|
|
38
41
|
safeParse(value: unknown): ParseResult<Map<K, V>>;
|
|
42
|
+
min(size: number, message?: string): VldMap<K, V>;
|
|
43
|
+
max(size: number, message?: string): VldMap<K, V>;
|
|
44
|
+
size(size: number, message?: string): VldMap<K, V>;
|
|
45
|
+
nonempty(message?: string): VldMap<K, V>;
|
|
39
46
|
}
|
package/dist/validators/map.js
CHANGED
|
@@ -1,214 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getMessages } from '../locales/runtime.js';
|
|
3
|
-
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
4
|
-
|
|
5
|
-
function createMapError(message) {
|
|
6
|
-
return new VldError([{ code: 'invalid_type', path: [], message }]);
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Immutable Map validator
|
|
10
|
-
*/
|
|
11
|
-
class VldMap extends VldBase {
|
|
12
|
-
/**
|
|
13
|
-
* Private constructor to enforce immutability
|
|
14
|
-
*/
|
|
15
|
-
constructor(keyValidator, valueValidator, errorMessage) {
|
|
16
|
-
super(VLD_VALIDATOR_TYPES.MAP);
|
|
17
|
-
this.keyValidator = keyValidator;
|
|
18
|
-
this.valueValidator = valueValidator;
|
|
19
|
-
this.errorMessage = errorMessage;
|
|
20
|
-
this._simpleKeyMode = this.getSimpleItemMode(keyValidator);
|
|
21
|
-
this._simpleValueMode = this.getSimpleItemMode(valueValidator);
|
|
22
|
-
this._simpleKeyValue = this._simpleKeyMode === 'literal' ? keyValidator.literal : undefined;
|
|
23
|
-
this._simpleValueValue = this._simpleValueMode === 'literal' ? valueValidator.literal : undefined;
|
|
24
|
-
}
|
|
25
|
-
get keySchema() {
|
|
26
|
-
return this.keyValidator;
|
|
27
|
-
}
|
|
28
|
-
get valueSchema() {
|
|
29
|
-
return this.valueValidator;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Create a new Map validator
|
|
33
|
-
*/
|
|
34
|
-
static create(keyValidator, valueValidator) {
|
|
35
|
-
return new VldMap(keyValidator, valueValidator);
|
|
36
|
-
}
|
|
37
|
-
getSimpleItemMode(validator) {
|
|
38
|
-
if (validator.isSimple !== true) {
|
|
39
|
-
return undefined;
|
|
40
|
-
}
|
|
41
|
-
switch (validator.validatorType) {
|
|
42
|
-
case VLD_VALIDATOR_TYPES.STRING:
|
|
43
|
-
return 'string';
|
|
44
|
-
case VLD_VALIDATOR_TYPES.NUMBER:
|
|
45
|
-
return 'number';
|
|
46
|
-
case VLD_VALIDATOR_TYPES.BOOLEAN:
|
|
47
|
-
return 'boolean';
|
|
48
|
-
case VLD_VALIDATOR_TYPES.BIGINT:
|
|
49
|
-
return 'bigint';
|
|
50
|
-
case VLD_VALIDATOR_TYPES.SYMBOL:
|
|
51
|
-
return 'symbol';
|
|
52
|
-
case VLD_VALIDATOR_TYPES.NULL:
|
|
53
|
-
return 'null';
|
|
54
|
-
case VLD_VALIDATOR_TYPES.UNDEFINED:
|
|
55
|
-
case VLD_VALIDATOR_TYPES.VOID:
|
|
56
|
-
return 'undefinedValue';
|
|
57
|
-
case VLD_VALIDATOR_TYPES.LITERAL:
|
|
58
|
-
return 'literal';
|
|
59
|
-
case VLD_VALIDATOR_TYPES.ANY:
|
|
60
|
-
case VLD_VALIDATOR_TYPES.UNKNOWN:
|
|
61
|
-
return 'passthrough';
|
|
62
|
-
default:
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
getSimpleItemError(mode, expected, received) {
|
|
67
|
-
switch (mode) {
|
|
68
|
-
case 'string':
|
|
69
|
-
return getMessages().invalidString;
|
|
70
|
-
case 'number':
|
|
71
|
-
return getMessages().invalidNumber;
|
|
72
|
-
case 'boolean':
|
|
73
|
-
return getMessages().invalidBoolean;
|
|
74
|
-
case 'bigint':
|
|
75
|
-
return getMessages().invalidBigint;
|
|
76
|
-
case 'symbol':
|
|
77
|
-
return getMessages().invalidSymbol;
|
|
78
|
-
case 'null':
|
|
79
|
-
return `Expected null, received ${typeof received}`;
|
|
80
|
-
case 'undefinedValue':
|
|
81
|
-
return getMessages().expectedUndefined;
|
|
82
|
-
case 'literal':
|
|
83
|
-
return getMessages().literalExpected(JSON.stringify(expected), JSON.stringify(received));
|
|
84
|
-
default:
|
|
85
|
-
return getMessages().invalidMap;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
parseSimpleItem(mode, expected, value) {
|
|
89
|
-
switch (mode) {
|
|
90
|
-
case 'string':
|
|
91
|
-
if (typeof value !== 'string') {
|
|
92
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
93
|
-
}
|
|
94
|
-
return value;
|
|
95
|
-
case 'number':
|
|
96
|
-
if (typeof value !== 'number' || isNaN(value)) {
|
|
97
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
98
|
-
}
|
|
99
|
-
return value;
|
|
100
|
-
case 'boolean':
|
|
101
|
-
if (typeof value !== 'boolean') {
|
|
102
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
103
|
-
}
|
|
104
|
-
return value;
|
|
105
|
-
case 'bigint':
|
|
106
|
-
if (typeof value !== 'bigint') {
|
|
107
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
108
|
-
}
|
|
109
|
-
return value;
|
|
110
|
-
case 'symbol':
|
|
111
|
-
if (typeof value !== 'symbol') {
|
|
112
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
113
|
-
}
|
|
114
|
-
return value;
|
|
115
|
-
case 'null':
|
|
116
|
-
if (value !== null) {
|
|
117
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
118
|
-
}
|
|
119
|
-
return null;
|
|
120
|
-
case 'undefinedValue':
|
|
121
|
-
if (value !== undefined) {
|
|
122
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
123
|
-
}
|
|
124
|
-
return undefined;
|
|
125
|
-
case 'literal':
|
|
126
|
-
if (value !== expected) {
|
|
127
|
-
throw new Error(this.getSimpleItemError(mode, expected, value));
|
|
128
|
-
}
|
|
129
|
-
return expected;
|
|
130
|
-
case 'passthrough':
|
|
131
|
-
return value;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Parse and validate a Map value
|
|
136
|
-
*/
|
|
137
|
-
parse(value) {
|
|
138
|
-
if (!(value instanceof Map)) {
|
|
139
|
-
throw new Error(this.errorMessage || getMessages().invalidMap);
|
|
140
|
-
}
|
|
141
|
-
return this.parseKnownMap(value);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Parse a value that has already passed the Map instance guard.
|
|
145
|
-
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
146
|
-
*/
|
|
147
|
-
parseKnownMap(value) {
|
|
148
|
-
const result = new Map();
|
|
149
|
-
const simpleKeyMode = this._simpleKeyMode;
|
|
150
|
-
const simpleValueMode = this._simpleValueMode;
|
|
151
|
-
if (simpleKeyMode === 'string' && simpleValueMode === 'number') {
|
|
152
|
-
for (const [key, val] of value) {
|
|
153
|
-
if (typeof key !== 'string') {
|
|
154
|
-
throw new Error(this.getSimpleItemError(simpleKeyMode, this._simpleKeyValue, key));
|
|
155
|
-
}
|
|
156
|
-
if (typeof val !== 'number' || isNaN(val)) {
|
|
157
|
-
throw new Error(this.getSimpleItemError(simpleValueMode, this._simpleValueValue, val));
|
|
158
|
-
}
|
|
159
|
-
result.set(key, val);
|
|
160
|
-
}
|
|
161
|
-
return result;
|
|
162
|
-
}
|
|
163
|
-
if (simpleKeyMode === 'string' && simpleValueMode === 'string') {
|
|
164
|
-
for (const [key, val] of value) {
|
|
165
|
-
if (typeof key !== 'string') {
|
|
166
|
-
throw new Error(this.getSimpleItemError(simpleKeyMode, this._simpleKeyValue, key));
|
|
167
|
-
}
|
|
168
|
-
if (typeof val !== 'string') {
|
|
169
|
-
throw new Error(this.getSimpleItemError(simpleValueMode, this._simpleValueValue, val));
|
|
170
|
-
}
|
|
171
|
-
result.set(key, val);
|
|
172
|
-
}
|
|
173
|
-
return result;
|
|
174
|
-
}
|
|
175
|
-
if (simpleKeyMode !== undefined && simpleValueMode !== undefined) {
|
|
176
|
-
const keyMode = simpleKeyMode;
|
|
177
|
-
const valueMode = simpleValueMode;
|
|
178
|
-
for (const [key, val] of value) {
|
|
179
|
-
const validKey = this.parseSimpleItem(keyMode, this._simpleKeyValue, key);
|
|
180
|
-
const validValue = this.parseSimpleItem(valueMode, this._simpleValueValue, val);
|
|
181
|
-
result.set(validKey, validValue);
|
|
182
|
-
}
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
for (const [key, val] of value) {
|
|
186
|
-
try {
|
|
187
|
-
const validKey = simpleKeyMode === undefined
|
|
188
|
-
? this.keyValidator.parse(key)
|
|
189
|
-
: this.parseSimpleItem(simpleKeyMode, this._simpleKeyValue, key);
|
|
190
|
-
const validValue = simpleValueMode === undefined
|
|
191
|
-
? this.valueValidator.parse(val)
|
|
192
|
-
: this.parseSimpleItem(simpleValueMode, this._simpleValueValue, val);
|
|
193
|
-
result.set(validKey, validValue);
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
throw new Error(error.message);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
return result;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Safely parse and validate a Map value
|
|
203
|
-
*/
|
|
204
|
-
safeParse(value) {
|
|
205
|
-
try {
|
|
206
|
-
return { success: true, data: this.parse(value) };
|
|
207
|
-
}
|
|
208
|
-
catch (error) {
|
|
209
|
-
return { success: false, error: createMapError(error.message) };
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export { VldMap };
|
|
1
|
+
import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{getMessages as t}from"../locales/runtime.js";import{V as s}from"../chunks/errors-core-CerMg2rq.js";class VldMap extends e{constructor(e,t,s,i=[]){super(r.MAP),this.keyValidator=e,this.valueValidator=t,this.errorMessage=s,this._checks=i,this._simpleKeyMode=this.getSimpleItemMode(e),this._simpleValueMode=this.getSimpleItemMode(t),this._simpleKeyValue="literal"===this._simpleKeyMode?e.literal:void 0,this._simpleValueValue="literal"===this._simpleValueMode?t.literal:void 0}get keySchema(){return this.keyValidator}get valueSchema(){return this.valueValidator}get keyType(){return this.keyValidator}get valueType(){return this.valueValidator}static create(e,r){return new VldMap(e,r)}getSimpleItemMode(e){if(!0===e.isSimple)switch(e.validatorType){case r.STRING:return"string";case r.NUMBER:return"number";case r.BOOLEAN:return"boolean";case r.BIGINT:return"bigint";case r.SYMBOL:return"symbol";case r.NULL:return"null";case r.UNDEFINED:case r.VOID:return"undefinedValue";case r.LITERAL:return"literal";case r.ANY:case r.UNKNOWN:return"passthrough";default:return}}getSimpleItemError(e,r,s){switch(e){case"string":return t().invalidString;case"number":return t().invalidNumber;case"boolean":return t().invalidBoolean;case"bigint":return t().invalidBigint;case"symbol":return t().invalidSymbol;case"null":return"Expected null, received "+typeof s;case"undefinedValue":return t().expectedUndefined;case"literal":return t().literalExpected(JSON.stringify(r),JSON.stringify(s));default:return t().invalidMap}}parseSimpleItem(e,r,t){switch(e){case"string":if("string"!=typeof t)throw new Error(this.getSimpleItemError(e,r,t));return t;case"number":if("number"!=typeof t||isNaN(t))throw new Error(this.getSimpleItemError(e,r,t));return t;case"boolean":if("boolean"!=typeof t)throw new Error(this.getSimpleItemError(e,r,t));return t;case"bigint":if("bigint"!=typeof t)throw new Error(this.getSimpleItemError(e,r,t));return t;case"symbol":if("symbol"!=typeof t)throw new Error(this.getSimpleItemError(e,r,t));return t;case"null":if(null!==t)throw new Error(this.getSimpleItemError(e,r,t));return null;case"undefinedValue":if(void 0!==t)throw new Error(this.getSimpleItemError(e,r,t));return;case"literal":if(t!==r)throw new Error(this.getSimpleItemError(e,r,t));return r;case"passthrough":return t}}parse(e){if(!(e instanceof Map))throw new Error(this.errorMessage||t().invalidMap);return this.parseKnownMap(e)}parseKnownMap(e){const r=new Map,t=this._simpleKeyMode,s=this._simpleValueMode;if("string"===t&&"number"===s)for(const[i,a]of e){if("string"!=typeof i)throw new Error(this.getSimpleItemError(t,this._simpleKeyValue,i));if("number"!=typeof a||isNaN(a))throw new Error(this.getSimpleItemError(s,this._simpleValueValue,a));r.set(i,a)}else if("string"===t&&"string"===s)for(const[i,a]of e){if("string"!=typeof i)throw new Error(this.getSimpleItemError(t,this._simpleKeyValue,i));if("string"!=typeof a)throw new Error(this.getSimpleItemError(s,this._simpleValueValue,a));r.set(i,a)}else if(void 0!==t&&void 0!==s){const i=t,a=s;for(const[t,s]of e){const e=this.parseSimpleItem(i,this._simpleKeyValue,t),n=this.parseSimpleItem(a,this._simpleValueValue,s);r.set(e,n)}}else for(const[i,a]of e)try{const e=void 0===t?this.keyValidator.parse(i):this.parseSimpleItem(t,this._simpleKeyValue,i),n=void 0===s?this.valueValidator.parse(a):this.parseSimpleItem(s,this._simpleValueValue,a);r.set(e,n)}catch(e){throw new Error(e.message)}for(const e of this._checks)if(!e.fn(r))throw new Error(e.message);return r}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(r=e.message,new s([{code:"invalid_type",path:[],message:r}]))}}var r}min(e,r){return new VldMap(this.keyValidator,this.valueValidator,this.errorMessage,[...this._checks,{fn:r=>r.size>=e,message:r||`Map must contain at least ${e} entries`}])}max(e,r){return new VldMap(this.keyValidator,this.valueValidator,this.errorMessage,[...this._checks,{fn:r=>r.size<=e,message:r||`Map must contain at most ${e} entries`}])}size(e,r){return new VldMap(this.keyValidator,this.valueValidator,this.errorMessage,[...this._checks,{fn:r=>r.size===e,message:r||`Map must contain exactly ${e} entries`}])}nonempty(e){return this.min(1,e||"Map cannot be empty")}}export{VldMap};
|
package/dist/validators/nan.js
CHANGED
|
@@ -1,38 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* VldNan - Validates that a value is NaN (Not a Number)
|
|
6
|
-
* Part of Zod 4 API parity implementation
|
|
7
|
-
*/
|
|
8
|
-
function createNanError(message) {
|
|
9
|
-
return new VldError([{ code: 'invalid_number', path: [], message }]);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* NaN validator - validates that a value is NaN
|
|
13
|
-
* Note: Uses Number.isNaN() which is more strict than global isNaN()
|
|
14
|
-
*/
|
|
15
|
-
class VldNan extends VldBase {
|
|
16
|
-
constructor() {
|
|
17
|
-
super(VLD_VALIDATOR_TYPES.NAN);
|
|
18
|
-
}
|
|
19
|
-
static create() {
|
|
20
|
-
return new VldNan();
|
|
21
|
-
}
|
|
22
|
-
parse(value) {
|
|
23
|
-
if (typeof value !== 'number' || !Number.isNaN(value)) {
|
|
24
|
-
throw new Error(`Expected NaN, received ${typeof value === 'number' ? 'a valid number' : typeof value}`);
|
|
25
|
-
}
|
|
26
|
-
return value;
|
|
27
|
-
}
|
|
28
|
-
safeParse(value) {
|
|
29
|
-
try {
|
|
30
|
-
return { success: true, data: this.parse(value) };
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return { success: false, error: createNanError(error.message) };
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export { VldNan };
|
|
1
|
+
import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{V as s}from"../chunks/errors-core-CerMg2rq.js";class VldNan extends e{constructor(){super(r.NAN)}static create(){return new VldNan}parse(e){if("number"!=typeof e||!Number.isNaN(e))throw new Error("Expected NaN, received "+("number"==typeof e?"a valid number":typeof e));return e}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(r=e.message,new s([{code:"invalid_number",path:[],message:r}]))}}var r}}export{VldNan};
|
package/dist/validators/never.js
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getMessages } from '../locales/runtime.js';
|
|
3
|
-
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Validator that never succeeds
|
|
7
|
-
*/
|
|
8
|
-
class VldNever extends VldBase {
|
|
9
|
-
/**
|
|
10
|
-
* Create a new never validator
|
|
11
|
-
*/
|
|
12
|
-
static create() {
|
|
13
|
-
return new VldNever();
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Parse never value (always fails)
|
|
17
|
-
*/
|
|
18
|
-
parse(_value) {
|
|
19
|
-
throw new Error(getMessages().neverType);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Safely parse never value (always fails)
|
|
23
|
-
*/
|
|
24
|
-
safeParse(_value) {
|
|
25
|
-
return {
|
|
26
|
-
success: false,
|
|
27
|
-
error: new VldError([{ code: 'invalid_type', path: [], message: getMessages().neverType }])
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export { VldNever };
|
|
1
|
+
import{VldBase as e}from"./base.js";import{getMessages as r}from"../locales/runtime.js";import{V as s}from"../chunks/errors-core-CerMg2rq.js";class VldNever extends e{static create(){return new VldNever}parse(e){throw new Error(r().neverType)}safeParse(e){return{success:!1,error:new s([{code:"invalid_type",path:[],message:r().neverType}])}}}export{VldNever};
|
package/dist/validators/null.js
CHANGED
|
@@ -1,40 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { V as VldError } from '../chunks/errors-core-BeiFUtZM.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* VldNull - Validates that a value is exactly null
|
|
6
|
-
* Part of Zod 4 API parity implementation
|
|
7
|
-
*/
|
|
8
|
-
function createNullError(message) {
|
|
9
|
-
return new VldError([{ code: 'invalid_type', path: [], message }]);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Null validator - validates that a value is exactly null
|
|
13
|
-
*/
|
|
14
|
-
class VldNull extends VldBase {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(VLD_VALIDATOR_TYPES.NULL);
|
|
17
|
-
}
|
|
18
|
-
static create() {
|
|
19
|
-
return new VldNull();
|
|
20
|
-
}
|
|
21
|
-
get isSimple() {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
parse(value) {
|
|
25
|
-
if (value !== null) {
|
|
26
|
-
throw new Error(`Expected null, received ${typeof value}`);
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
safeParse(value) {
|
|
31
|
-
try {
|
|
32
|
-
return { success: true, data: this.parse(value) };
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
return { success: false, error: createNullError(error.message) };
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export { VldNull };
|
|
1
|
+
import{VldBase as e,VLD_VALIDATOR_TYPES as r}from"./base.js";import{V as s}from"../chunks/errors-core-CerMg2rq.js";class VldNull extends e{constructor(){super(r.NULL)}static create(){return new VldNull}get isSimple(){return!0}parse(e){if(null!==e)throw new Error("Expected null, received "+typeof e);return null}safeParse(e){try{return{success:!0,data:this.parse(e)}}catch(e){return{success:!1,error:(r=e.message,new s([{code:"invalid_type",path:[],message:r}]))}}var r}}export{VldNull};
|
|
@@ -3,6 +3,15 @@ import { VldBase, ParseResult, ValidatorType, type ErrorParam } from './base.js'
|
|
|
3
3
|
* Type for number validation check functions
|
|
4
4
|
*/
|
|
5
5
|
type NumberCheck = (value: number) => boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Metadata for a single number constraint, enabling Zod 4-compatible issues.
|
|
8
|
+
*/
|
|
9
|
+
interface NumberCheckMeta {
|
|
10
|
+
readonly kind: 'min' | 'max' | 'int' | 'gt' | 'lt' | 'multiple_of' | 'finite' | 'safe' | 'other';
|
|
11
|
+
readonly value?: number;
|
|
12
|
+
readonly inclusive?: boolean;
|
|
13
|
+
readonly message: string | undefined;
|
|
14
|
+
}
|
|
6
15
|
interface NumberJSONSchemaHints {
|
|
7
16
|
type?: 'number' | 'integer';
|
|
8
17
|
minimum?: number;
|
|
@@ -19,6 +28,7 @@ interface NumberValidatorConfig {
|
|
|
19
28
|
readonly errorMessage: string | undefined;
|
|
20
29
|
readonly validatorType?: ValidatorType;
|
|
21
30
|
readonly jsonSchema: NumberJSONSchemaHints | undefined;
|
|
31
|
+
readonly checkMetas: ReadonlyArray<NumberCheckMeta> | undefined;
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
24
34
|
* Immutable number validator with chainable methods
|
|
@@ -28,6 +38,7 @@ export declare class VldNumber extends VldBase<number, number> {
|
|
|
28
38
|
private readonly _checks;
|
|
29
39
|
private readonly _isSimple;
|
|
30
40
|
private readonly _fastCheckMode;
|
|
41
|
+
private readonly _checkMetas;
|
|
31
42
|
/**
|
|
32
43
|
* Protected constructor to allow extension while maintaining immutability
|
|
33
44
|
*/
|
|
@@ -43,20 +54,33 @@ export declare class VldNumber extends VldBase<number, number> {
|
|
|
43
54
|
* Used by VldObject for optimized fast-path dispatch
|
|
44
55
|
*/
|
|
45
56
|
get isSimple(): boolean;
|
|
57
|
+
get minValue(): number | null;
|
|
58
|
+
get maxValue(): number | null;
|
|
59
|
+
get isInt(): boolean;
|
|
60
|
+
get isFinite(): boolean;
|
|
61
|
+
get format(): string | null;
|
|
46
62
|
/**
|
|
47
63
|
* Create a new number validator
|
|
48
64
|
*/
|
|
49
65
|
static create(): VldNumber;
|
|
50
66
|
/**
|
|
51
67
|
* Parse and validate a number value
|
|
68
|
+
* Zod 4 behavior: Infinity and NaN are rejected by default (they are not valid numbers).
|
|
52
69
|
*/
|
|
53
70
|
parse(value: unknown): number;
|
|
71
|
+
/**
|
|
72
|
+
* Build the Zod 4-compatible VldIssue for a failed number check.
|
|
73
|
+
*/
|
|
74
|
+
private _createCheckIssue;
|
|
75
|
+
/**
|
|
76
|
+
* Run all checks against a known number and return the index of the first failing check, or -1.
|
|
77
|
+
*/
|
|
78
|
+
private _findFailingCheck;
|
|
54
79
|
/**
|
|
55
80
|
* Parse a value that has already passed the number type guard.
|
|
56
81
|
* @internal Used by object validators to avoid duplicate hot-path checks.
|
|
57
82
|
*/
|
|
58
83
|
parseKnownNumber(value: number): number;
|
|
59
|
-
private passesChecks;
|
|
60
84
|
/**
|
|
61
85
|
* Safely parse and validate a number value
|
|
62
86
|
*/
|