Socket
Socket
Sign inDemoInstall

zod

Package Overview
Dependencies
0
Maintainers
1
Versions
360
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.11 to 1.0.12

4

lib/index.d.ts

@@ -24,3 +24,5 @@ import { ZodString, ZodStringDef } from './types/string';

declare const arrayType: <T extends ZodAny>(schema: T) => ZodArray<T>;
declare const objectType: <T extends import("./types/base").ZodRawShape>(shape: T) => ZodObject<T>;
declare const objectType: <T extends import("./types/base").ZodRawShape>(shape: T) => ZodObject<T, {
strict: true;
}>;
declare const unionType: <T extends [ZodAny, ZodAny, ...ZodAny[]]>(types: T) => ZodUnion<T>;

@@ -27,0 +29,0 @@ declare const intersectionType: <T extends ZodAny, U extends ZodAny>(left: T, right: U) => ZodIntersection<T, U>;

@@ -77,2 +77,10 @@ "use strict";

var shape = def.shape;
if (def.strict) {
var shapeKeys_1 = Object.keys(def.shape);
var objKeys = Object.keys(obj);
var extraKeys = objKeys.filter(function (k) { return shapeKeys_1.indexOf(k) === -1; });
if (extraKeys.length) {
throw ZodError_1.ZodError.fromString("Unexpected key(s) in object: " + extraKeys.map(function (k) { return "'" + k + "'"; }).join(', '));
}
}
var objectError = ZodError_1.ZodError.create([]);

@@ -155,4 +163,6 @@ for (var key in shape) {

case z.ZodTypes.literal:
if (obj === def.value)
return obj;
var literalValue = def.value;
if (typeof literalValue === 'string')
if (obj === def.value)
return obj;
throw ZodError_1.ZodError.fromString(obj + " !== Literal<" + def.value + ">");

@@ -159,0 +169,0 @@ case z.ZodTypes.enum:

@@ -11,43 +11,25 @@ "use strict";

var z = __importStar(require("."));
// import { ZodError } from './ZodError';
// const asdf = z.object({
// arrstring: z.array(z.object({ str: z.string() })),
// tupletest: z.tuple([z.string(), z.number()]),
// objarr: z.array(
// z.object({
// inner: z.boolean(),
// }),
// ),
// });
// z.array(z.string()).parse([1234, 567]);
var person = z.object({
name: z.object({
first: z.string(),
last: z.string(),
}),
var dogSchema = z
.object({
name: z.string(),
neutered: z.boolean(),
})
.merge(z.object({
age: z.number(),
address: z.array(z.string()),
}))
.nonstrict();
var dog = dogSchema.parse({
name: 'Spot',
neutered: true,
age: 12,
color: 'brown',
});
try {
// asdf.parse({
// arrstring: [{ str: 'sdjfksd' }],
// tupletest: ['colin', 2.5],
// objarr: [
// {
// inner: true,
// },
// ],
// wrwerwr: 1234,
// });
person.parse({
name: { first: 'Dave', last: 42 },
age: 'threeve',
address: ['123 Maple Street', {}],
});
console.log('successful parse!');
}
catch (err) {
// console.log(JSON.stringify(err.errors, null, 2));
console.log(err.message);
}
console.log(JSON.stringify(dog, null, 2));
// type Dog = z.TypeOf<typeof dogSchema>;
// const spot: Dog = {
// name: 'Spot',
// age: 8,
// neutered: true,
// color: 'brown', //
// };
// type Primitive = string | number | boolean | null | undefined;

@@ -60,75 +42,182 @@ // type Compound<U extends Primitive = Primitive> =

// | [Compound<U>, ...Compound<U>[]];
// type Json<U extends Primitive = Primitive> = U | Compound<U>;
// this function infers the EXACT type of the value passed into it
// and returns it as a const will full type information
// const infer1 = <T extends Json>(arg: T): T => {
// type Json<U extends Primitive> = U | Compound<U>;
// // this function infers the EXACT type of the value passed into it
// // and returns it as a const will full type information
// export const inferLiteral = <U extends Primitive, T extends Json<U>>(arg: T): T => {
// return arg;
// };
// const infer2 = <U extends Json<Primitive>>(arg: U): U extends Json<infer T> ? Json<T> : never => {
// return arg as Json<T>;
// };
// const inferLiteral = infer1;
// const test1 = inferLiteral('asdf'); // typeof test1 => "asdf"
// const test2 = inferLiteral(341); // typeof test2 => 341
// const test3 = inferLiteral(false); // typeof test3 => false
// const test4 = inferLiteral(null); // typeof test4 => null
// const test5 = inferLiteral(undefined); // typeof test5 => undefined
// const test6 = inferLiteral([]); // typeof test6 => []
// const test7 = inferLiteral(['asdf']); // typeof test6 => []
// const test8 = inferLiteral([{ asdf: 'qer' }]); // typeof test7 => [{ asdf: 'qer' }]
// const test9 = inferLiteral({
// asdf: [
// {
// asdf: 'qwer',
// asdfn: 12,
// asdfb: false,
// wer: {},
// lkulk: [false, 'asdf', 1234],
// empt: [],
// emptr: ['asdf'],
// },
// ],
// // import { ZodError } from './ZodError';
// // const asdf = z.object({
// // arrstring: z.array(z.object({ str: z.string() })),
// // tupletest: z.tuple([z.string(), z.number()]),
// // objarr: z.array(
// // z.object({
// // inner: z.boolean(),
// // }),
// // ),
// // });
// // z.array(z.string()).parse([1234, 567]);
// // enum Key {
// // One,
// // Two
// // }
// // abstract class BaseClass{
// // abstract key: Key
// // }
// // class Class1 extends BaseClass {
// // readonly key = Key.One;
// // one: string = 'one :)';
// // }
// // class Class2 extends BaseClass {
// // readonly key = Key.Two;
// // two: string = 'two!';
// // }
// // type SomeSubclass = Class1 | Class2;
// // const run = ()=>{
// // const qwer: SomeSubclass = "asdf" as any;
// // switch (qwer.key) {
// // case Key.One:
// // // const asdf = qwer.one;
// // break;
// // case Key.Two:
// // break
// // default:
// // break
// // }
// // }
// // run()
// // const qwer = z.literal([{
// // asdf: Infinity,
// // qwer:1234
// // }]);
// const obj1 = z
// .object({
// str: z.string(),
// })
// type obj1 = z.TypeOf<typeof obj1>;
// const obj1lax = obj1.nonstrict();
// type obj1lax = z.TypeOf<typeof obj1lax>;
// type obj2p = (typeof obj1lax)['_params']
// const obj2 = z.object({ num: z.number() });
// const obj3 = obj1.merge(obj2).nonstrict();
// type obj3 = z.TypeOf<typeof obj3>;
// type obj3p = typeof obj3['_params'];
// // type obj3params = (typeof obj3)['_params'];
// obj1.parse({
// str: 'qwer',
// lkjf: 1234,
// });
// const und = z.literal(undefined);
// const MyEnum = z.enum([z.literal('Hello'), z.literal('There'), z.literal('Bobby')]);
// MyEnum.parse('Bobby');
// type MyEnum = z.Infer<typeof MyEnum>;
// const CellText = z.object({
// kind: z.literal('text'),
// body: z.string(),
// obj3.parse({
// str: 'asdf',
// num: 234,
// });
// const CellCode = z.object({
// kind: z.literal('code'),
// code: z.string(),
// });
// const Schema = z.array(
// z.object({
// category: z.string(),
// cells: z.array(z.union([CellText, CellCode])).nonempty(),
// }),
// );
// // const y: ['asdf', 'qwer'] = ['asdf', 'qwer'];
// type U = ['asdf', 'qwer']
// type Tail<Tuple extends any[]> = ((...args: Tuple) => any) extends (_: any, ..._1: infer Rest) => any
// ? Rest extends any[] ? Rest : never
// : never;
// export type ArrayKeys = keyof any[];
// export type Indices<T> = Exclude<keyof T, ArrayKeys>;
// type UM<T extends string[]> = {[k in Indices<T>]: T[k] extends string ? z.ZodLiteral<T[k]> : never};
// type UMU = UM<U>
// type p = UMU[0]
// type Ad = Tail<string[]>
// type Mapper<T extends string[]> = {
// empty: T,
// single: T,
// many: [T[0], ...ForceArray<Mapper<T>>],
// never: never
// }[T extends [] ? 'empty' : T extends [any] ? 'single' : T extends any[] ? 'many' : 'never'];
// type ForceArray<T extends any[]> = T extends (infer U) ? U extends any[] ? U : never : never;
// type MapRest<T extends string[]> = { 0: Mapper<Tail<T>> extends any[] ? Mapper<Tail<T>> : never, 1: never }[true ? 0 : 1]
// type MU = MapRest<["wer", "asdf"]>
// // if (!Schema.is(y)) {
// // y[0].cells[0].kind; // => "text" | "code"
// // throw new Error("adsf")
// // }
// // type dfgfg = z.Infer<typeof dfgfg>
// // const q: dfgfg = {
// // asdf: 'asdf',
// // qwer: 234,
// // };
// // console.log(qwer.);
// // const y:any = "asdf";
// // person.assert(y);
// try {
// // asdf.parse({
// // arrstring: [{ str: 'sdjfksd' }],
// // tupletest: ['colin', 2.5],
// // objarr: [
// // {
// // inner: true,
// // },
// // ],
// // wrwerwr: 1234,
// // });
// // person.parse({
// // name: [{ first: 'Dave', last: 42 }],
// // age: 'threeve',
// // address: ['123 Maple Street', {}],
// // });
// console.log('successful parse!');
// } catch (err) {
// // console.log(JSON.stringify(err.errors, null, 2));
// console.log(err.message);
// }
// // type Primitive = string | number | boolean | null | undefined;
// // type Compound<U extends Primitive = Primitive> =
// // | U
// // | { [name: string]: Compound<U> }
// // | []
// // | [Compound<U>]
// // | [Compound<U>, ...Compound<U>[]];
// // type Json<U extends Primitive = Primitive> = U | Compound<U>;
// // this function infers the EXACT type of the value passed into it
// // and returns it as a const will full type information
// // const infer1 = <T extends Json>(arg: T): T => {
// // return arg;
// // };
// // const infer2 = <U extends Json<Primitive>>(arg: U): U extends Json<infer T> ? Json<T> : never => {
// // return arg as Json<T>;
// // };
// // const inferLiteral = infer1;
// // const test1 = inferLiteral('asdf'); // typeof test1 => "asdf"
// // const test2 = inferLiteral(341); // typeof test2 => 341
// // const test3 = inferLiteral(false); // typeof test3 => false
// // const test4 = inferLiteral(null); // typeof test4 => null
// // const test5 = inferLiteral(undefined); // typeof test5 => undefined
// // const test6 = inferLiteral([]); // typeof test6 => []
// // const test7 = inferLiteral(['asdf']); // typeof test6 => []
// // const test8 = inferLiteral([{ asdf: 'qer' }]); // typeof test7 => [{ asdf: 'qer' }]
// // const test9 = inferLiteral({
// // asdf: [
// // {
// // asdf: 'qwer',
// // asdfn: 12,
// // asdfb: false,
// // wer: {},
// // lkulk: [false, 'asdf', 1234],
// // empt: [],
// // emptr: ['asdf'],
// // },
// // ],
// // });
// // const und = z.literal(undefined);
// // const MyEnum = z.enum([z.literal('Hello'), z.literal('There'), z.literal('Bobby')]);
// // MyEnum.parse('Bobby');
// // type MyEnum = z.Infer<typeof MyEnum>;
// // const CellText = z.object({
// // kind: z.literal('text'),
// // body: z.string(),
// // });
// // const CellCode = z.object({
// // kind: z.literal('code'),
// // code: z.string(),
// // });
// // const Schema = z.array(
// // z.object({
// // category: z.string(),
// // cells: z.array(z.union([CellText, CellCode])).nonempty(),
// // }),
// // );
// // // const y: ['asdf', 'qwer'] = ['asdf', 'qwer'];
// // type U = ['asdf', 'qwer']
// // type Tail<Tuple extends any[]> = ((...args: Tuple) => any) extends (_: any, ..._1: infer Rest) => any
// // ? Rest extends any[] ? Rest : never
// // : never;
// // export type ArrayKeys = keyof any[];
// // export type Indices<T> = Exclude<keyof T, ArrayKeys>;
// // type UM<T extends string[]> = {[k in Indices<T>]: T[k] extends string ? z.ZodLiteral<T[k]> : never};
// // type UMU = UM<U>
// // type p = UMU[0]
// // type Ad = Tail<string[]>
// // type Mapper<T extends string[]> = {
// // empty: T,
// // single: T,
// // many: [T[0], ...ForceArray<Mapper<T>>],
// // never: never
// // }[T extends [] ? 'empty' : T extends [any] ? 'single' : T extends any[] ? 'many' : 'never'];
// // type ForceArray<T extends any[]> = T extends (infer U) ? U extends any[] ? U : never : never;
// // type MapRest<T extends string[]> = { 0: Mapper<Tail<T>> extends any[] ? Mapper<Tail<T>> : never, 1: never }[true ? 0 : 1]
// // type MU = MapRest<["wer", "asdf"]>
// // // if (!Schema.is(y)) {
// // // y[0].cells[0].kind; // => "text" | "code"
// // // throw new Error("adsf")
// // // }
//# sourceMappingURL=playground.js.map

@@ -10,2 +10,3 @@ import { ZodTuple } from './tuple';

object = "object",
interface = "interface",
union = "union",

@@ -12,0 +13,0 @@ intersection = "intersection",

@@ -13,2 +13,3 @@ "use strict";

ZodTypes["object"] = "object";
ZodTypes["interface"] = "interface";
ZodTypes["union"] = "union";

@@ -27,3 +28,4 @@ ZodTypes["intersection"] = "intersection";

var ZodType = /** @class */ (function () {
// assert: (u: unknown) => asserts u is Type = u => {
// assert: zodAssertion<Type> = (value: unknown) => zodAssert(this, value);
// (u: unknown) => asserts u is Type = u => {
// try {

@@ -30,0 +32,0 @@ // this.parse(u);

@@ -6,8 +6,7 @@ import * as z from './base';

declare type Primitive = string | number | boolean | null | undefined;
declare type LiteralValue = Primitive;
export interface ZodLiteralDef<T extends LiteralValue = LiteralValue> extends z.ZodTypeDef {
export interface ZodLiteralDef<T extends any = any> extends z.ZodTypeDef {
t: z.ZodTypes.literal;
value: T;
}
export declare class ZodLiteral<T extends LiteralValue> extends z.ZodType<T, ZodLiteralDef<T>> {
export declare class ZodLiteral<T extends any> extends z.ZodType<T, ZodLiteralDef<T>> {
optional: () => ZodUnion<[this, ZodUndefined]>;

@@ -14,0 +13,0 @@ nullable: () => ZodUnion<[this, ZodNull]>;

@@ -36,2 +36,3 @@ "use strict";

}
// static create = <U extends Primitive, T extends LiteralValue<U>>(value: T): ZodLiteral<T> => {
ZodLiteral.create = function (value) {

@@ -38,0 +39,0 @@ return new ZodLiteral({

@@ -5,5 +5,10 @@ import * as z from './base';

import { ZodUnion } from './union';
export interface ZodShapeDef<T extends z.ZodRawShape = z.ZodRawShape> extends z.ZodTypeDef {
t: z.ZodTypes.object;
shape: T;
}
export interface ZodObjectDef<T extends z.ZodRawShape = z.ZodRawShape> extends z.ZodTypeDef {
t: z.ZodTypes.object;
shape: T;
strict: boolean;
}

@@ -23,15 +28,36 @@ declare type OptionalKeys<T extends z.ZodRawShape> = {

declare type ObjectType<T extends z.ZodRawShape> = Flatten<ObjectIntersection<T>>;
export declare class ZodObject<T extends z.ZodRawShape> extends z.ZodType<ObjectType<T>, // { [k in keyof T]: T[k]['_type'] },
declare type MergeObjectParams<First extends ZodObjectParams, Second extends ZodObjectParams> = {
strict: First['strict'] extends false ? false : Second['strict'] extends false ? false : true;
};
interface ZodObjectParams {
strict: boolean;
}
export declare class ZodObject<T extends z.ZodRawShape, Params extends ZodObjectParams = {
strict: true;
}> extends z.ZodType<Params['strict'] extends true ? ObjectType<T> : Flatten<ObjectType<T> & {
[k: string]: any;
}>, // { [k in keyof T]: T[k]['_type'] },
ZodObjectDef<T>> {
readonly _params: Params;
toJSON: () => {
t: z.ZodTypes.object;
shape: {
[x: string]: object;
[x: string]: any;
}[];
};
merge: <U extends ZodObject<any>>(other: U) => ZodObject<T & U>;
nonstrict: () => ZodObject<T, Flatten<{ [k in Exclude<keyof Params, "strict">]: Params[k]; } & {
strict: false;
}>>;
/**
* Prior to zod@1.0.12 there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/
merge: <MergeShape extends z.ZodRawShape, MergeParams extends ZodObjectParams>(other: ZodObject<MergeShape, MergeParams>) => ZodObject<T & MergeShape, MergeObjectParams<Params, MergeParams>>;
optional: () => ZodUnion<[this, ZodUndefined]>;
nullable: () => ZodUnion<[this, ZodNull]>;
static create: <T_1 extends z.ZodRawShape>(shape: T_1) => ZodObject<T_1>;
static create: <T_1 extends z.ZodRawShape>(shape: T_1) => ZodObject<T_1, {
strict: true;
}>;
}
export {};

@@ -39,5 +39,32 @@ "use strict";

var intersection_1 = require("./intersection");
// type adsf = OptionalKeys<{name:ZodString}>;
// type asdfqwe = {name:ZodString}['name']['_type']
// type lkjljk = (undefined) extends (string) ? true : false
var mergeShapes = function (first, second) {
var firstKeys = Object.keys(first);
var secondKeys = Object.keys(second);
var sharedKeys = firstKeys.filter(function (k) { return secondKeys.indexOf(k) !== -1; });
var sharedShape = {};
for (var _i = 0, sharedKeys_1 = sharedKeys; _i < sharedKeys_1.length; _i++) {
var k = sharedKeys_1[_i];
sharedShape[k] = intersection_1.ZodIntersection.create(first[k], second[k]);
}
return __assign(__assign(__assign({}, first), second), sharedShape);
};
var mergeObjects = function (first) { return function (second) {
var mergedShape = mergeShapes(first._def.shape, second._def.shape);
var merged = new ZodObject({
t: z.ZodTypes.object,
strict: first._def.strict && second._def.strict,
shape: mergedShape,
});
return merged;
}; };
var objectDefToJson = function (def) { return ({
t: def.t,
shape: Object.assign({}, Object.keys(def.shape).map(function (k) {
var _a;
return (_a = {},
_a[k] = def.shape[k].toJSON(),
_a);
})),
}); };
// type SetKeyTest = SetKey<{asdf:string},"asdf",number>;
var ZodObject = /** @class */ (function (_super) {

@@ -47,28 +74,17 @@ __extends(ZodObject, _super);

var _this = _super !== null && _super.apply(this, arguments) || this;
_this.toJSON = function () { return ({
t: _this._def.t,
shape: Object.assign({}, Object.keys(_this._def.shape).map(function (k) {
var _a;
return (_a = {},
_a[k] = _this._def.shape[k].toJSON(),
_a);
})),
}); };
_this.merge = function (other) {
var currShape = _this._def.shape;
var mergeShape = other._def.shape;
var currKeys = Object.keys(currShape);
var mergeKeys = Object.keys(mergeShape);
var sharedKeys = currKeys.filter(function (k) { return mergeKeys.indexOf(k) !== -1; });
var sharedShape = {};
for (var _i = 0, sharedKeys_1 = sharedKeys; _i < sharedKeys_1.length; _i++) {
var k = sharedKeys_1[_i];
sharedShape[k] = intersection_1.ZodIntersection.create(currShape[k], mergeShape[k]);
}
var merged = new ZodObject({
_this.toJSON = function () { return objectDefToJson(_this._def); };
_this.nonstrict = function () {
return new ZodObject({
shape: _this._def.shape,
strict: false,
t: z.ZodTypes.object,
shape: __assign(__assign(__assign({}, _this._def.shape), other._def.shape), sharedShape),
});
return merged;
};
// interface = ()=>
/**
* Prior to zod@1.0.12 there was a bug in the
* inferred type of merged objects. Please
* upgrade if you are experiencing issues.
*/
_this.merge = mergeObjects(_this);
_this.optional = function () { return union_1.ZodUnion.create([_this, undefined_1.ZodUndefined.create()]); };

@@ -81,2 +97,3 @@ _this.nullable = function () { return union_1.ZodUnion.create([_this, null_1.ZodNull.create()]); };

t: z.ZodTypes.object,
strict: true,
shape: shape,

@@ -88,2 +105,34 @@ });

exports.ZodObject = ZodObject;
// export interface ZodInterfaceDef<T extends z.ZodRawShape = z.ZodRawShape> extends z.ZodTypeDef {
// t: z.ZodTypes.interface;
// shape: T; //{ [k in keyof T]: T[k]['_def'] };
// }
// const mergeInterfaces = <U extends z.ZodRawShape>(first: ZodInterface<U>) => <T extends z.ZodRawShape>(
// second: ZodInterface<T>,
// ): ZodInterface<T & U> => {
// const mergedShape = mergeShapes(first._def.shape, second._def.shape);
// const merged: ZodInterface<T & U> = ZodInterface.create(mergedShape);
// return merged;
// };
// export class ZodInterface<T extends z.ZodRawShape> extends z.ZodType<
// ObjectType<{ [k in keyof T]: T[k] }> & { [k: string]: any }, // { [k in keyof T]: T[k]['_type'] },
// ZodInterfaceDef<T>
// > {
// toJSON = () => objectDefToJson(this._def);
// toObject = () => ZodObject.create(this._def.shape);
// /**
// * Prior to zod@1.0.12 there was a bug in the
// * inferred type of merged objects. Please
// * upgrade if you are experiencing issues.
// */
// merge: <U extends z.ZodRawShape>(other: ZodInterface<U>) => ZodInterface<Flatten<T & U>> = mergeInterfaces(this);
// optional: () => ZodUnion<[this, ZodUndefined]> = () => ZodUnion.create([this, ZodUndefined.create()]);
// nullable: () => ZodUnion<[this, ZodNull]> = () => ZodUnion.create([this, ZodNull.create()]);
// static create = <T extends z.ZodRawShape>(shape: T): ZodInterface<T> => {
// return new ZodInterface({
// t: z.ZodTypes.interface,
// shape,
// });
// };
// }
//# sourceMappingURL=object.js.map

@@ -53,3 +53,3 @@ "use strict";

var path = _a.path, message = _a.message;
return "`" + path.join('.') + "`: " + message;
return path.length ? "`" + path.join('.') + "`: " + message : "" + message;
})

@@ -56,0 +56,0 @@ .join('\n');

{
"name": "zod",
"version": "1.0.11",
"version": "1.0.12",
"description": "TypeScript-first schema declaration and validation library with static type inference",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -140,3 +140,2 @@ # Zod

name: z.string(),
age: z.number(),
neutered: z.boolean(),

@@ -150,3 +149,2 @@ });

name:string;
age: number;
neutered: boolean;

@@ -158,3 +156,2 @@ }

name: 'Cujo',
age: 4,
neutered: true,

@@ -165,6 +162,54 @@ }); // passes, returns Dog

name: 'Fido',
age: 2,
}; // TypeError: missing required property `neutered`
```
### Unknown keys
IMPORTANT: By default, Zod object schemas _do not_ allow unknown keys.
```ts
dogSchema.parse({
name: 'Spot',
neutered: true,
color: 'brown',
}); // Error(`Unexpected keys in object: 'color'`)
```
This is an intentional decision to make Zod's behavior consistent with TypeScript. Consider this:
```ts
const spot: Dog = {
name: 'Spot',
neutered: true,
color: 'brown',
};
// TypeError: Object literal may only specify known
// properties, and 'color' does not exist in type Dog
```
TypeScript doesn't allow unknown keys when assigning to an object type, so neither does Zod (by default). If you want to allow this, just call the `.nonstrict()` method on any object schema:
```ts
const dogSchemaNonstrict = dogSchema.nonstrict();
dogSchemaNonstrict.parse({
name: 'Spot',
neutered: true,
color: 'brown',
}); // passes
```
This change is reflected in the inferred type as well:
```ts
type NonstrictDog = z.TypeOf<typeof dogSchemaNonstrict>;
/*
{
name:string;
neutered: boolean;
[k:string]: any;
}
*/
```
## Arrays

@@ -511,5 +556,5 @@

The table below summarizes the feature differences. Below the table there are more involved discussions of certain alternatives, where necessary.
<!-- The table below summarizes the feature differences. Below the table there are more involved discussions of certain alternatives, where necessary. -->
| Feature | [Zod](https://github.com/vriad) | [Joi](https://github.com/hapijs/joi) | [Yup](https://github.com/jquense/yup) | [io-ts](https://github.com/gcanti/io-ts) | [Runtypes](https://github.com/pelotom/runtypes) | [ow](https://github.com/sindresorhus/ow) | [class-validator](https://github.com/typestack/class-validator) |
<!-- | Feature | [Zod](https://github.com/vriad) | [Joi](https://github.com/hapijs/joi) | [Yup](https://github.com/jquense/yup) | [io-ts](https://github.com/gcanti/io-ts) | [Runtypes](https://github.com/pelotom/runtypes) | [ow](https://github.com/sindresorhus/ow) | [class-validator](https://github.com/typestack/class-validator) |
| ---------------------------------------------------------------------------------------------------------------------- | :-----------------------------: | :----------------------------------: | :-----------------------------------: | :--------------------------------------: | :---------------------------------------------: | :--------------------------------------: | :-------------------------------------------------------------: |

@@ -548,3 +593,3 @@ | <abbr title='Any ability to extract a TypeScript type from a validator instance counts.'>Type inference</abbr> | 🟢 | 🔴 | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |

Rich Errors
Branded
Branded -->

@@ -551,0 +596,0 @@ ### Joi

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc