zod
Advanced tools
Comparing version 1.10.0-alpha.1 to 1.10.0-alpha.2
"use strict"; | ||
// import * as z from '.'; | ||
// import { ZodCodec } from './types/codec'; | ||
// const test = ZodCodec.create(z.string(), z.string(), x => x.trim().toUpperCase()); | ||
// const adsf = test.parse(' asdf12345 asdf asdfas '); | ||
// console.log(adsf); | ||
// // import { ZodCodec } from './types/codec'; | ||
// const test = z.codec(z.string(), z.string(), x => x.trim().toUpperCase()); | ||
// const adsf = test.parse(' asdf '); | ||
// console.log(adsf); // => 'ASDF' | ||
// const stringToNumber = z.number().accepts(z.string().or(z.number()), data => parseFloat(`${data}`)); | ||
// console.log(stringToNumber.parse('5') * 5); // 25 | ||
// const FormData = z | ||
@@ -8,0 +10,0 @@ // .object({ |
import { ParseParams, MakeErrorData } from '../parser'; | ||
import { util } from '../helpers/util'; | ||
import { ZodArray, ZodUnion, ZodNull, ZodUndefined } from '..'; | ||
import { ZodArray, ZodUnion, ZodNull, ZodUndefined, ZodCodec } from '..'; | ||
import { CustomError } from '../ZodError'; | ||
@@ -66,3 +66,5 @@ export declare enum ZodTypes { | ||
array: () => ZodArray<this>; | ||
accepts: <U extends ZodType<any>, Tx extends (arg: U['_type']) => this['_type']>(x: U, transformer: Tx) => ZodCodec<U, this>; | ||
or: <U extends ZodType<any>>(arg: U) => ZodUnion<[this, U]>; | ||
} | ||
export {}; |
@@ -72,2 +72,12 @@ "use strict"; | ||
this.array = function () { return __1.ZodArray.create(_this); }; | ||
// pre: <T extends string>( | ||
// input: T, | ||
// transformer: (arg: T) => Type, | ||
// ) => any = (input, transformer) => 'adsf'; | ||
this.accepts = function (input, transformer) { | ||
return __1.ZodCodec.create(input, _this, transformer); | ||
}; | ||
this.or = function (arg) { | ||
return __1.ZodUnion.create([_this, arg]); | ||
}; | ||
this.parse = parser_1.ZodParser(def); | ||
@@ -74,0 +84,0 @@ this._def = def; |
{ | ||
"name": "zod", | ||
"version": "1.10.0-alpha.1", | ||
"version": "1.10.0-alpha.2", | ||
"description": "TypeScript-first schema declaration and validation library with static type inference", | ||
@@ -5,0 +5,0 @@ "main": "./lib/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
258342
3364