@quentinadam/zod 0.1.1 → 0.1.2
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/dist/zod.d.ts +1 -1
- package/dist/zod.js +6 -6
- package/package.json +1 -1
package/dist/zod.d.ts
CHANGED
|
@@ -53,5 +53,5 @@ declare function createRecordSchema<T>(schema: Schema<T>): Schema<Record<string,
|
|
|
53
53
|
declare function createUnionSchema<T extends unknown[]>(schemas: {
|
|
54
54
|
[K in keyof T]: Schema<T[K]>;
|
|
55
55
|
}): Schema<T[number]>;
|
|
56
|
-
declare function createLiteralSchema<T extends string | number | boolean | null>(
|
|
56
|
+
declare function createLiteralSchema<T extends string | number | boolean | null>(litteral: T): Schema<T>;
|
|
57
57
|
export { createArraySchema as array, createBigIntSchema as bigint, createBooleanSchema as boolean, createDateSchema as date, createInstanceofSchema as instanceof, createLiteralSchema as literal, createNullSchema as null, createNumberSchema as number, createObjectSchema as object, createRecordSchema as record, createStringSchema as string, createTupleSchema as tuple, createUndefinedSchema as undefined, createUnionSchema as union, createUnknownSchema as unknown, };
|
package/dist/zod.js
CHANGED
|
@@ -237,15 +237,15 @@ function createUnionSchema(schemas) {
|
|
|
237
237
|
},
|
|
238
238
|
});
|
|
239
239
|
}
|
|
240
|
-
function createLiteralSchema(
|
|
241
|
-
const inputType = JSON.stringify(
|
|
240
|
+
function createLiteralSchema(litteral) {
|
|
241
|
+
const inputType = JSON.stringify(litteral);
|
|
242
242
|
return new Schema({
|
|
243
243
|
inputType,
|
|
244
|
-
parseFn: (
|
|
245
|
-
if (
|
|
246
|
-
throw new Error(`Expected ${inputType}, got ${
|
|
244
|
+
parseFn: (value) => {
|
|
245
|
+
if (value !== litteral) {
|
|
246
|
+
throw new Error(`Expected ${inputType}, got ${JSON.stringify(value)}`);
|
|
247
247
|
}
|
|
248
|
-
return
|
|
248
|
+
return litteral;
|
|
249
249
|
},
|
|
250
250
|
});
|
|
251
251
|
}
|