@stryke/zod 0.1.0 → 0.2.0
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 +23 -0
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -3
- package/dist/is-zod-type-B-jL80F-.mjs +197 -0
- package/dist/is-zod-type-B-jL80F-.mjs.map +1 -0
- package/dist/is-zod-type-CDtbhw8L.d.mts +30 -0
- package/dist/is-zod-type-CDtbhw8L.d.mts.map +1 -0
- package/dist/is-zod-type-RGE-O0aK.cjs +214 -0
- package/dist/is-zod-type-x0dit7lA.d.cts +30 -0
- package/dist/is-zod-type-x0dit7lA.d.cts.map +1 -0
- package/dist/is-zod-type.cjs +4 -34
- package/dist/is-zod-type.d.cts +2 -30
- package/dist/is-zod-type.d.mts +3 -30
- package/dist/is-zod-type.mjs +2 -33
- package/dist/schema-B6usLZOz.mjs +44 -0
- package/dist/schema-B6usLZOz.mjs.map +1 -0
- package/dist/schema-DQPkBDAQ.d.mts +32 -0
- package/dist/schema-DQPkBDAQ.d.mts.map +1 -0
- package/dist/schema-s8jVY_-l.d.cts +32 -0
- package/dist/schema-s8jVY_-l.d.cts.map +1 -0
- package/dist/schema-wGX9lE9h.cjs +82 -0
- package/dist/schema.cjs +3 -32
- package/dist/schema.d.cts +2 -22
- package/dist/schema.d.mts +3 -22
- package/dist/schema.mjs +2 -31
- package/dist/types-4nTrnOUu.d.cts +20 -0
- package/dist/types-4nTrnOUu.d.cts.map +1 -0
- package/dist/types-UlEWkGXF.d.mts +20 -0
- package/dist/types-UlEWkGXF.d.mts.map +1 -0
- package/dist/types.d.cts +2 -20
- package/dist/types.d.mts +2 -20
- package/dist/types.mjs +0 -1
- package/package.json +50 -8
- package/dist/_virtual/rolldown_runtime.cjs +0 -29
- package/dist/is-zod-type.d.cts.map +0 -1
- package/dist/is-zod-type.d.mts.map +0 -1
- package/dist/is-zod-type.mjs.map +0 -1
- package/dist/schema.d.cts.map +0 -1
- package/dist/schema.d.mts.map +0 -1
- package/dist/schema.mjs.map +0 -1
- package/dist/type-checks/src/get-object-tag.cjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs +0 -15
- package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
- package/dist/type-checks/src/is-empty.cjs +0 -20
- package/dist/type-checks/src/is-empty.mjs +0 -21
- package/dist/type-checks/src/is-empty.mjs.map +0 -1
- package/dist/type-checks/src/is-non-null-object.cjs +0 -16
- package/dist/type-checks/src/is-non-null-object.mjs +0 -17
- package/dist/type-checks/src/is-non-null-object.mjs.map +0 -1
- package/dist/type-checks/src/is-null.cjs +0 -12
- package/dist/type-checks/src/is-null.mjs +0 -12
- package/dist/type-checks/src/is-null.mjs.map +0 -1
- package/dist/type-checks/src/is-object.cjs +0 -19
- package/dist/type-checks/src/is-object.mjs +0 -20
- package/dist/type-checks/src/is-object.mjs.map +0 -1
- package/dist/type-checks/src/is-plain-object.cjs +0 -63
- package/dist/type-checks/src/is-plain-object.mjs +0 -64
- package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set-object.cjs +0 -19
- package/dist/type-checks/src/is-set-object.mjs +0 -20
- package/dist/type-checks/src/is-set-object.mjs.map +0 -1
- package/dist/type-checks/src/is-set.cjs +0 -19
- package/dist/type-checks/src/is-set.mjs +0 -20
- package/dist/type-checks/src/is-set.mjs.map +0 -1
- package/dist/type-checks/src/is-undefined.cjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs +0 -8
- package/dist/type-checks/src/is-undefined.mjs.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Changelog for Stryke - Zod
|
|
4
|
+
|
|
5
|
+
## [0.1.1](https://github.com/storm-software/stryke/releases/tag/zod%400.1.1) (03/02/2026)
|
|
6
|
+
|
|
7
|
+
### Miscellaneous
|
|
8
|
+
|
|
9
|
+
- **zod:** Added types to `exports` in package.json file ([2abe7f5b](https://github.com/storm-software/stryke/commit/2abe7f5b))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- **zod:** Resolve issue with bundled project code ([d7c1e067](https://github.com/storm-software/stryke/commit/d7c1e067))
|
|
14
|
+
|
|
15
|
+
## [0.1.0](https://github.com/storm-software/stryke/releases/tag/zod%400.1.0) (03/02/2026)
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- **zod:** Initial check-in of the `zod` package ([b4cf898c](https://github.com/storm-software/stryke/commit/b4cf898c))
|
|
20
|
+
|
|
21
|
+
### Updated Dependencies
|
|
22
|
+
|
|
23
|
+
- Updated **type-checks** to **v0.5.26**
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
1
|
+
const require_schema = require('./schema-wGX9lE9h.cjs');
|
|
2
|
+
const require_is_zod_type = require('./is-zod-type-RGE-O0aK.cjs');
|
|
3
|
+
require('./types.cjs');
|
|
3
4
|
|
|
4
5
|
exports.extractJsonSchema = require_schema.extractJsonSchema;
|
|
6
|
+
exports.extractJsonSchema7 = require_schema.extractJsonSchema7;
|
|
5
7
|
exports.isZod3Type = require_is_zod_type.isZod3Type;
|
|
6
8
|
exports.isZod4Type = require_is_zod_type.isZod4Type;
|
|
7
9
|
exports.isZodType = require_is_zod_type.isZodType;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { extractJsonSchema } from "./schema.cjs";
|
|
4
|
-
export { ZodType, ZodTypeInfo, ZodTypeKind, extractJsonSchema, isZod3Type, isZod4Type, isZodType };
|
|
1
|
+
import { n as ZodTypeInfo, r as ZodTypeKind, t as ZodType } from "./types-4nTrnOUu.cjs";
|
|
2
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-x0dit7lA.cjs";
|
|
3
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-s8jVY_-l.cjs";
|
|
4
|
+
export { ZodType, ZodTypeInfo, ZodTypeKind, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { extractJsonSchema } from "./schema.mjs";
|
|
4
|
-
export { ZodType, ZodTypeInfo, ZodTypeKind, extractJsonSchema, isZod3Type, isZod4Type, isZodType };
|
|
1
|
+
import { n as ZodTypeInfo, r as ZodTypeKind, t as ZodType } from "./types-UlEWkGXF.mjs";
|
|
2
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-CDtbhw8L.mjs";
|
|
3
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-DQPkBDAQ.mjs";
|
|
4
|
+
export { ZodType, ZodTypeInfo, ZodTypeKind, extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { extractJsonSchema } from "./schema.mjs";
|
|
1
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-B-jL80F-.mjs";
|
|
2
|
+
import { n as extractJsonSchema7, t as extractJsonSchema } from "./schema-B6usLZOz.mjs";
|
|
3
|
+
import "./types.mjs";
|
|
3
4
|
|
|
4
|
-
export { extractJsonSchema, isZod3Type, isZod4Type, isZodType };
|
|
5
|
+
export { extractJsonSchema, extractJsonSchema7, isZod3Type, isZod4Type, isZodType };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
//#region ../type-checks/src/get-object-tag.ts
|
|
2
|
+
/**
|
|
3
|
+
* Gets the `toStringTag` of `obj`.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The obj to query.
|
|
6
|
+
* @returns Returns the `toStringTag`.
|
|
7
|
+
*/
|
|
8
|
+
const getObjectTag = (value) => {
|
|
9
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
10
|
+
return Object.prototype.toString.call(value);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region ../type-checks/src/is-plain-object.ts
|
|
15
|
+
/**
|
|
16
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
17
|
+
* and has a `typeof` result of "object".
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* isObjectLike({})
|
|
22
|
+
* // => true
|
|
23
|
+
*
|
|
24
|
+
* isObjectLike([1, 2, 3])
|
|
25
|
+
* // => true
|
|
26
|
+
*
|
|
27
|
+
* isObjectLike(Function)
|
|
28
|
+
* // => false
|
|
29
|
+
*
|
|
30
|
+
* isObjectLike(null)
|
|
31
|
+
* // => false
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param value - The value to check.
|
|
35
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
36
|
+
*/
|
|
37
|
+
const isObjectLike = (obj) => {
|
|
38
|
+
return typeof obj === "object" && obj !== null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* function Foo() {
|
|
46
|
+
* this.a = 1
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* isPlainObject(new Foo)
|
|
50
|
+
* // => false
|
|
51
|
+
*
|
|
52
|
+
* isPlainObject([1, 2, 3])
|
|
53
|
+
* // => false
|
|
54
|
+
*
|
|
55
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
56
|
+
* // => true
|
|
57
|
+
*
|
|
58
|
+
* isPlainObject(Object.create(null))
|
|
59
|
+
* // => true
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @param obj - The value to check.
|
|
63
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
64
|
+
*/
|
|
65
|
+
const isPlainObject = (obj) => {
|
|
66
|
+
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
67
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
68
|
+
let proto = obj;
|
|
69
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
70
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region ../type-checks/src/is-object.ts
|
|
75
|
+
/**
|
|
76
|
+
* Check if the provided value's type is `Object`
|
|
77
|
+
*
|
|
78
|
+
* @param value - The value to type check
|
|
79
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
80
|
+
*/
|
|
81
|
+
const isObject = (value) => {
|
|
82
|
+
try {
|
|
83
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region ../type-checks/src/is-null.ts
|
|
91
|
+
const isNull = (value) => {
|
|
92
|
+
try {
|
|
93
|
+
return value === null;
|
|
94
|
+
} catch {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region ../type-checks/src/is-undefined.ts
|
|
101
|
+
const isUndefined = (value) => {
|
|
102
|
+
return value === void 0;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
//#region ../type-checks/src/is-empty.ts
|
|
107
|
+
/**
|
|
108
|
+
* Check if the provided value's type is `null` or `undefined`
|
|
109
|
+
*
|
|
110
|
+
* @param value - The value to type check
|
|
111
|
+
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
112
|
+
*/
|
|
113
|
+
const isEmpty = (value) => {
|
|
114
|
+
try {
|
|
115
|
+
return isUndefined(value) || isNull(value);
|
|
116
|
+
} catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
//#region ../type-checks/src/is-set.ts
|
|
123
|
+
/**
|
|
124
|
+
* The inverse of the `isEmpty` function
|
|
125
|
+
*
|
|
126
|
+
* @param value - The value to type check
|
|
127
|
+
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
128
|
+
*/
|
|
129
|
+
const isSet = (value) => {
|
|
130
|
+
try {
|
|
131
|
+
return !isEmpty(value);
|
|
132
|
+
} catch {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region ../type-checks/src/is-non-null-object.ts
|
|
139
|
+
/**
|
|
140
|
+
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
141
|
+
*
|
|
142
|
+
* @param value - The value to type check
|
|
143
|
+
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
144
|
+
*/
|
|
145
|
+
const isNonNullObject = (value) => {
|
|
146
|
+
return isSet(value) && isObject(value);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region ../type-checks/src/is-set-object.ts
|
|
151
|
+
/**
|
|
152
|
+
* Check if the provided value's type is an object with some fields set
|
|
153
|
+
*
|
|
154
|
+
* @param value - The value to type check
|
|
155
|
+
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
156
|
+
*/
|
|
157
|
+
const isSetObject = (value) => {
|
|
158
|
+
try {
|
|
159
|
+
return isNonNullObject(value) && Object.keys(value).length > 0;
|
|
160
|
+
} catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/is-zod-type.ts
|
|
167
|
+
/**
|
|
168
|
+
* Type guard to check if a given value is a Zod schema of version 3.
|
|
169
|
+
*
|
|
170
|
+
* @param type - The value to check.
|
|
171
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
172
|
+
*/
|
|
173
|
+
function isZod3Type(type) {
|
|
174
|
+
return isSetObject(type) && "_def" in type && "typeName" in type._def;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Type guard to check if a given value is a Zod schema of version 4.
|
|
178
|
+
*
|
|
179
|
+
* @param type - The value to check.
|
|
180
|
+
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
181
|
+
*/
|
|
182
|
+
function isZod4Type(type) {
|
|
183
|
+
return isSetObject(type) && "_zod" in type && "def" in type._zod;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
187
|
+
*
|
|
188
|
+
* @param type - The value to check.
|
|
189
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
190
|
+
*/
|
|
191
|
+
function isZodType(type) {
|
|
192
|
+
return isZod3Type(type) || isZod4Type(type);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
//#endregion
|
|
196
|
+
export { isZod4Type as n, isZodType as r, isZod3Type as t };
|
|
197
|
+
//# sourceMappingURL=is-zod-type-B-jL80F-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-zod-type-B-jL80F-.mjs","names":[],"sources":["../../type-checks/src/get-object-tag.ts","../../type-checks/src/is-plain-object.ts","../../type-checks/src/is-object.ts","../../type-checks/src/is-null.ts","../../type-checks/src/is-undefined.ts","../../type-checks/src/is-empty.ts","../../type-checks/src/is-set.ts","../../type-checks/src/is-non-null-object.ts","../../type-checks/src/is-set-object.ts","../src/is-zod-type.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/* eslint-disable ts/no-unsafe-function-type */\n/* eslint-disable ts/no-unsafe-call */\n\nimport type { NativeClass } from \"@stryke/types/base\";\nimport { isPlainObject } from \"./is-plain-object\";\n\n// Prepare\nconst isClassRegex = /^class\\s|^function\\s+[A-Z]/;\nconst isConventionalClassRegex = /^function\\s+[A-Z]/;\nconst isNativeClassRegex = /^class\\s/;\n\n/** Is ES6+ class */\nexport function isNativeClass(value?: any): value is NativeClass {\n // NOTE TO DEVELOPER: If any of this changes, isClass must also be updated\n return (\n typeof value === \"function\" && isNativeClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is a conventional class\n *\n * @remarks\n * Is Conventional Class\n * Looks for function with capital first letter MyClass\n * First letter is the 9th character\n * If changed, isClass must also be updated\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is a conventional class\n */\nexport function isConventionalClass(value?: any): value is Function {\n return (\n typeof value === \"function\" &&\n isConventionalClassRegex.test(value.toString())\n );\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport function isClass(value?: any): value is Function | NativeClass; // only guarantee of truth type, not of validity\nexport function isClass(value?: any): boolean {\n return typeof value === \"function\" && isClassRegex.test(value.toString());\n}\n\n/**\n * Check if the provided value's type is `Object`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object`\n */\nexport const isObject = (value: unknown): value is object => {\n try {\n return (\n typeof value === \"object\" ||\n (Boolean(value) && value?.constructor === Object) ||\n isPlainObject(value)\n );\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isObject } from \"./is-object\";\nimport { isSet } from \"./is-set\";\n\n/**\n * Check if the provided value's type is `Object` and is not `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`\n */\nexport const isNonNullObject = (value: any): value is NonNullable<object> => {\n return isSet(value) && isObject(value);\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNonNullObject } from \"./is-non-null-object\";\n\n/**\n * Check if the provided value's type is an object with some fields set\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is an object with some fields se\n */\nexport const isSetObject = (value: unknown): value is NonNullable<object> => {\n try {\n return isNonNullObject(value) && Object.keys(value).length > 0;\n } catch {\n return false;\n }\n};\n","/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type * as z3 from \"zod/v3\";\nimport type * as z4 from \"zod/v4/core\";\n\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type { ZodType } from \"./types\";\n\n/**\n * Type guard to check if a given value is a Zod schema of version 3.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod schema, false otherwise.\n */\nexport function isZod3Type(type: unknown): type is z3.ZodTypeAny {\n return (\n isSetObject(type) &&\n \"_def\" in type &&\n \"typeName\" in (type as z3.ZodTypeAny)._def\n );\n}\n\n/**\n * Type guard to check if a given value is a Zod schema of version 4.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod v4 schema, false otherwise.\n */\nexport function isZod4Type(type: unknown): type is z4.$ZodType {\n return (\n isSetObject(type) && \"_zod\" in type && \"def\" in (type as z4.$ZodType)._zod\n );\n}\n\n/**\n * Type guard to check if a given value is a Zod schema of either version 3 or 4.\n *\n * @param type - The value to check.\n * @returns True if the value is a Zod schema, false otherwise.\n */\nexport function isZodType(type: unknown): type is ZodType {\n return isZod3Type(type) || isZod4Type(type);\n}\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;ACe9C,MAAa,gBAAgB,QAAiB;AAC5C,QAAO,OAAO,QAAQ,YAAY,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4B5C,MAAa,iBAAiB,QAAqC;AACjE,KAAI,CAAC,aAAa,IAAI,IAAI,aAAa,IAAI,KAAK,kBAC9C,QAAO;AAET,KAAI,OAAO,eAAe,IAAI,KAAK,KACjC,QAAO;CAET,IAAI,QAAQ;AACZ,QAAO,OAAO,eAAe,MAAM,KAAK,KACtC,SAAQ,OAAO,eAAe,MAAM;AAEtC,QAAO,OAAO,eAAe,IAAI,KAAK;;;;;;;;;;;ACVxC,MAAa,YAAY,UAAoC;AAC3D,KAAI;AACF,SACE,OAAO,UAAU,YAChB,QAAQ,MAAM,IAAI,OAAO,gBAAgB,UAC1C,cAAc,MAAM;SAEhB;AACN,SAAO;;;;;;AC/DX,MAAa,UAAU,UAAkC;AACvD,KAAI;AACF,SAAO,UAAU;SACX;AACN,SAAO;;;;;;ACJX,MAAa,eAAe,UAAuC;AACjE,QAAO,UAAU;;;;;;;;;;;ACYnB,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO;;;;;;;;;;;;ACTX,MAAa,SAAS,UAAkD;AACtE,KAAI;AACF,SAAO,CAAC,QAAQ,MAAM;SAChB;AACN,SAAO;;;;;;;;;;;;ACHX,MAAa,mBAAmB,UAA6C;AAC3E,QAAO,MAAM,MAAM,IAAI,SAAS,MAAM;;;;;;;;;;;ACFxC,MAAa,eAAe,UAAiD;AAC3E,KAAI;AACF,SAAO,gBAAgB,MAAM,IAAI,OAAO,KAAK,MAAM,CAAC,SAAS;SACvD;AACN,SAAO;;;;;;;;;;;;ACAX,SAAgB,WAAW,MAAsC;AAC/D,QACE,YAAY,KAAK,IACjB,UAAU,QACV,cAAe,KAAuB;;;;;;;;AAU1C,SAAgB,WAAW,MAAoC;AAC7D,QACE,YAAY,KAAK,IAAI,UAAU,QAAQ,SAAU,KAAqB;;;;;;;;AAU1E,SAAgB,UAAU,MAAgC;AACxD,QAAO,WAAW,KAAK,IAAI,WAAW,KAAK"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as ZodType } from "./types-UlEWkGXF.mjs";
|
|
2
|
+
import * as z4 from "zod/v4/core";
|
|
3
|
+
import * as z3 from "zod/v3";
|
|
4
|
+
|
|
5
|
+
//#region src/is-zod-type.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a given value is a Zod schema of version 3.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The value to check.
|
|
11
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
declare function isZod3Type(type: unknown): type is z3.ZodTypeAny;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a given value is a Zod schema of version 4.
|
|
16
|
+
*
|
|
17
|
+
* @param type - The value to check.
|
|
18
|
+
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
declare function isZod4Type(type: unknown): type is z4.$ZodType;
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
23
|
+
*
|
|
24
|
+
* @param type - The value to check.
|
|
25
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
26
|
+
*/
|
|
27
|
+
declare function isZodType(type: unknown): type is ZodType;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { isZod4Type as n, isZodType as r, isZod3Type as t };
|
|
30
|
+
//# sourceMappingURL=is-zod-type-CDtbhw8L.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-zod-type-CDtbhw8L.d.mts","names":[],"sources":["../src/is-zod-type.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAcA;AAYA;;iBA1BgB,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBActC,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBAYtC,SAAA,yBAAkC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../type-checks/src/get-object-tag.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gets the `toStringTag` of `obj`.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The obj to query.
|
|
7
|
+
* @returns Returns the `toStringTag`.
|
|
8
|
+
*/
|
|
9
|
+
const getObjectTag = (value) => {
|
|
10
|
+
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
11
|
+
return Object.prototype.toString.call(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region ../type-checks/src/is-plain-object.ts
|
|
16
|
+
/**
|
|
17
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
18
|
+
* and has a `typeof` result of "object".
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* isObjectLike({})
|
|
23
|
+
* // => true
|
|
24
|
+
*
|
|
25
|
+
* isObjectLike([1, 2, 3])
|
|
26
|
+
* // => true
|
|
27
|
+
*
|
|
28
|
+
* isObjectLike(Function)
|
|
29
|
+
* // => false
|
|
30
|
+
*
|
|
31
|
+
* isObjectLike(null)
|
|
32
|
+
* // => false
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @param value - The value to check.
|
|
36
|
+
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
37
|
+
*/
|
|
38
|
+
const isObjectLike = (obj) => {
|
|
39
|
+
return typeof obj === "object" && obj !== null;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* function Foo() {
|
|
47
|
+
* this.a = 1
|
|
48
|
+
* }
|
|
49
|
+
*
|
|
50
|
+
* isPlainObject(new Foo)
|
|
51
|
+
* // => false
|
|
52
|
+
*
|
|
53
|
+
* isPlainObject([1, 2, 3])
|
|
54
|
+
* // => false
|
|
55
|
+
*
|
|
56
|
+
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
57
|
+
* // => true
|
|
58
|
+
*
|
|
59
|
+
* isPlainObject(Object.create(null))
|
|
60
|
+
* // => true
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param obj - The value to check.
|
|
64
|
+
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
65
|
+
*/
|
|
66
|
+
const isPlainObject = (obj) => {
|
|
67
|
+
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
68
|
+
if (Object.getPrototypeOf(obj) === null) return true;
|
|
69
|
+
let proto = obj;
|
|
70
|
+
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
71
|
+
return Object.getPrototypeOf(obj) === proto;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
75
|
+
//#region ../type-checks/src/is-object.ts
|
|
76
|
+
/**
|
|
77
|
+
* Check if the provided value's type is `Object`
|
|
78
|
+
*
|
|
79
|
+
* @param value - The value to type check
|
|
80
|
+
* @returns An indicator specifying if the value provided is of type `Object`
|
|
81
|
+
*/
|
|
82
|
+
const isObject = (value) => {
|
|
83
|
+
try {
|
|
84
|
+
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
85
|
+
} catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region ../type-checks/src/is-null.ts
|
|
92
|
+
const isNull = (value) => {
|
|
93
|
+
try {
|
|
94
|
+
return value === null;
|
|
95
|
+
} catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region ../type-checks/src/is-undefined.ts
|
|
102
|
+
const isUndefined = (value) => {
|
|
103
|
+
return value === void 0;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region ../type-checks/src/is-empty.ts
|
|
108
|
+
/**
|
|
109
|
+
* Check if the provided value's type is `null` or `undefined`
|
|
110
|
+
*
|
|
111
|
+
* @param value - The value to type check
|
|
112
|
+
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
113
|
+
*/
|
|
114
|
+
const isEmpty = (value) => {
|
|
115
|
+
try {
|
|
116
|
+
return isUndefined(value) || isNull(value);
|
|
117
|
+
} catch {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region ../type-checks/src/is-set.ts
|
|
124
|
+
/**
|
|
125
|
+
* The inverse of the `isEmpty` function
|
|
126
|
+
*
|
|
127
|
+
* @param value - The value to type check
|
|
128
|
+
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
129
|
+
*/
|
|
130
|
+
const isSet = (value) => {
|
|
131
|
+
try {
|
|
132
|
+
return !isEmpty(value);
|
|
133
|
+
} catch {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region ../type-checks/src/is-non-null-object.ts
|
|
140
|
+
/**
|
|
141
|
+
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
142
|
+
*
|
|
143
|
+
* @param value - The value to type check
|
|
144
|
+
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
145
|
+
*/
|
|
146
|
+
const isNonNullObject = (value) => {
|
|
147
|
+
return isSet(value) && isObject(value);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region ../type-checks/src/is-set-object.ts
|
|
152
|
+
/**
|
|
153
|
+
* Check if the provided value's type is an object with some fields set
|
|
154
|
+
*
|
|
155
|
+
* @param value - The value to type check
|
|
156
|
+
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
157
|
+
*/
|
|
158
|
+
const isSetObject = (value) => {
|
|
159
|
+
try {
|
|
160
|
+
return isNonNullObject(value) && Object.keys(value).length > 0;
|
|
161
|
+
} catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/is-zod-type.ts
|
|
168
|
+
/**
|
|
169
|
+
* Type guard to check if a given value is a Zod schema of version 3.
|
|
170
|
+
*
|
|
171
|
+
* @param type - The value to check.
|
|
172
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
173
|
+
*/
|
|
174
|
+
function isZod3Type(type) {
|
|
175
|
+
return isSetObject(type) && "_def" in type && "typeName" in type._def;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Type guard to check if a given value is a Zod schema of version 4.
|
|
179
|
+
*
|
|
180
|
+
* @param type - The value to check.
|
|
181
|
+
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
182
|
+
*/
|
|
183
|
+
function isZod4Type(type) {
|
|
184
|
+
return isSetObject(type) && "_zod" in type && "def" in type._zod;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
188
|
+
*
|
|
189
|
+
* @param type - The value to check.
|
|
190
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
191
|
+
*/
|
|
192
|
+
function isZodType(type) {
|
|
193
|
+
return isZod3Type(type) || isZod4Type(type);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//#endregion
|
|
197
|
+
Object.defineProperty(exports, 'isZod3Type', {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return isZod3Type;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
Object.defineProperty(exports, 'isZod4Type', {
|
|
204
|
+
enumerable: true,
|
|
205
|
+
get: function () {
|
|
206
|
+
return isZod4Type;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
Object.defineProperty(exports, 'isZodType', {
|
|
210
|
+
enumerable: true,
|
|
211
|
+
get: function () {
|
|
212
|
+
return isZodType;
|
|
213
|
+
}
|
|
214
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { t as ZodType } from "./types-4nTrnOUu.cjs";
|
|
2
|
+
import * as z3 from "zod/v3";
|
|
3
|
+
import * as z4 from "zod/v4/core";
|
|
4
|
+
|
|
5
|
+
//#region src/is-zod-type.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Type guard to check if a given value is a Zod schema of version 3.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The value to check.
|
|
11
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
12
|
+
*/
|
|
13
|
+
declare function isZod3Type(type: unknown): type is z3.ZodTypeAny;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a given value is a Zod schema of version 4.
|
|
16
|
+
*
|
|
17
|
+
* @param type - The value to check.
|
|
18
|
+
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
declare function isZod4Type(type: unknown): type is z4.$ZodType;
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
23
|
+
*
|
|
24
|
+
* @param type - The value to check.
|
|
25
|
+
* @returns True if the value is a Zod schema, false otherwise.
|
|
26
|
+
*/
|
|
27
|
+
declare function isZodType(type: unknown): type is ZodType;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { isZod4Type as n, isZodType as r, isZod3Type as t };
|
|
30
|
+
//# sourceMappingURL=is-zod-type-x0dit7lA.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-zod-type-x0dit7lA.d.cts","names":[],"sources":["../src/is-zod-type.ts"],"sourcesContent":[],"mappings":";;;;;;;;AA8BA;AAcA;AAYA;;iBA1BgB,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBActC,UAAA,yBAAmC,EAAA,CAAG;;;;;;;iBAYtC,SAAA,yBAAkC"}
|
package/dist/is-zod-type.cjs
CHANGED
|
@@ -1,35 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_is_zod_type = require('./is-zod-type-RGE-O0aK.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
* @param type - The value to check.
|
|
8
|
-
* @returns True if the value is a Zod schema, false otherwise.
|
|
9
|
-
*/
|
|
10
|
-
function isZod3Type(type) {
|
|
11
|
-
return require_is_set_object.isSetObject(type) && "_def" in type && "typeName" in type._def;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Type guard to check if a given value is a Zod schema of version 4.
|
|
15
|
-
*
|
|
16
|
-
* @param type - The value to check.
|
|
17
|
-
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
function isZod4Type(type) {
|
|
20
|
-
return require_is_set_object.isSetObject(type) && "_zod" in type && "def" in type._zod;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
24
|
-
*
|
|
25
|
-
* @param type - The value to check.
|
|
26
|
-
* @returns True if the value is a Zod schema, false otherwise.
|
|
27
|
-
*/
|
|
28
|
-
function isZodType(type) {
|
|
29
|
-
return isZod3Type(type) || isZod4Type(type);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
exports.isZod3Type = isZod3Type;
|
|
34
|
-
exports.isZod4Type = isZod4Type;
|
|
35
|
-
exports.isZodType = isZodType;
|
|
3
|
+
exports.isZod3Type = require_is_zod_type.isZod3Type;
|
|
4
|
+
exports.isZod4Type = require_is_zod_type.isZod4Type;
|
|
5
|
+
exports.isZodType = require_is_zod_type.isZodType;
|
package/dist/is-zod-type.d.cts
CHANGED
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import * as z4 from "zod/v4/core";
|
|
4
|
-
|
|
5
|
-
//#region src/is-zod-type.d.ts
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Type guard to check if a given value is a Zod schema of version 3.
|
|
9
|
-
*
|
|
10
|
-
* @param type - The value to check.
|
|
11
|
-
* @returns True if the value is a Zod schema, false otherwise.
|
|
12
|
-
*/
|
|
13
|
-
declare function isZod3Type(type: unknown): type is z3.ZodTypeAny;
|
|
14
|
-
/**
|
|
15
|
-
* Type guard to check if a given value is a Zod schema of version 4.
|
|
16
|
-
*
|
|
17
|
-
* @param type - The value to check.
|
|
18
|
-
* @returns True if the value is a Zod v4 schema, false otherwise.
|
|
19
|
-
*/
|
|
20
|
-
declare function isZod4Type(type: unknown): type is z4.$ZodType;
|
|
21
|
-
/**
|
|
22
|
-
* Type guard to check if a given value is a Zod schema of either version 3 or 4.
|
|
23
|
-
*
|
|
24
|
-
* @param type - The value to check.
|
|
25
|
-
* @returns True if the value is a Zod schema, false otherwise.
|
|
26
|
-
*/
|
|
27
|
-
declare function isZodType(type: unknown): type is ZodType;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { isZod3Type, isZod4Type, isZodType };
|
|
30
|
-
//# sourceMappingURL=is-zod-type.d.cts.map
|
|
1
|
+
import { n as isZod4Type, r as isZodType, t as isZod3Type } from "./is-zod-type-x0dit7lA.cjs";
|
|
2
|
+
export { isZod3Type, isZod4Type, isZodType };
|