New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

myzod

Package Overview
Dependencies
Maintainers
0
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

myzod - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

6

libs/index.d.ts
import { IntersectionType } from './types';
import { ValidationError, Type, StringType, NumberType, LiteralType, ObjectType, ArrayType, UnionType, PartialType, TupleType, DateType, LazyType, UndefinedType, NullType, NullableType, EnumType, BooleanType, UnknownType, NumberOptions, Literal, ObjectShape, ObjectOptions, AnyType, ArrayOptions, UnionOptions, PartialOpts, IntersectionResult, DeepPartialShape, PartialShape, Eval, ToUnion, StringTypes, OptionalType, BigIntOptions, BigIntType, StringOptions, EnumOptions } from './types';
export { ValidationError, Type, Infer, AnyType, ObjectShape, NumberType, BooleanType, StringType, UndefinedType, NullType, ObjectType, ArrayType, TupleType, NullableType, OptionalType, MappedType, DateType, UnknownType, UnionType, IntersectionType, } from './types';
declare const keySignature: unique symbol;
export { keySignature };
import { keySignature, ValidationError, Type, StringType, NumberType, LiteralType, ObjectType, ArrayType, UnionType, PartialType, TupleType, DateType, LazyType, UndefinedType, NullType, NullableType, EnumType, BooleanType, UnknownType, NumberOptions, Literal, ObjectShape, ObjectOptions, AnyType, ArrayOptions, UnionOptions, PartialOpts, IntersectionResult, DeepPartialShape, PartialShape, Eval, ToUnion, StringTypes, OptionalType, BigIntOptions, BigIntType, StringOptions, EnumOptions } from './types';
export { keySignature, ValidationError, Type, Infer, AnyType, ObjectShape, NumberType, BooleanType, StringType, UndefinedType, NullType, ObjectType, ArrayType, TupleType, NullableType, OptionalType, MappedType, DateType, UnknownType, UnionType, IntersectionType, } from './types';
export declare const string: (opts?: StringOptions) => StringType;

@@ -7,0 +5,0 @@ export declare const boolean: () => BooleanType;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.required = exports.enum = exports.null = exports.undefined = exports.omit = exports.pick = exports.partial = exports.lazy = exports.date = exports.tuple = exports.dictionary = exports.record = exports.literals = exports.intersection = exports.union = exports.array = exports.object = exports.literal = exports.unknown = exports.bigint = exports.number = exports.boolean = exports.string = exports.keySignature = exports.IntersectionType = exports.UnionType = exports.UnknownType = exports.DateType = exports.OptionalType = exports.NullableType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.NullType = exports.UndefinedType = exports.StringType = exports.BooleanType = exports.NumberType = exports.Type = exports.ValidationError = void 0;
exports.required = exports.enum = exports.null = exports.undefined = exports.omit = exports.pick = exports.partial = exports.lazy = exports.date = exports.tuple = exports.dictionary = exports.record = exports.literals = exports.intersection = exports.union = exports.array = exports.object = exports.literal = exports.unknown = exports.bigint = exports.number = exports.boolean = exports.string = exports.IntersectionType = exports.UnionType = exports.UnknownType = exports.DateType = exports.OptionalType = exports.NullableType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.NullType = exports.UndefinedType = exports.StringType = exports.BooleanType = exports.NumberType = exports.Type = exports.ValidationError = exports.keySignature = void 0;
const types_1 = require("./types");
const types_2 = require("./types");
var types_3 = require("./types");
Object.defineProperty(exports, "keySignature", { enumerable: true, get: function () { return types_3.keySignature; } });
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return types_3.ValidationError; } });

@@ -24,4 +25,2 @@ Object.defineProperty(exports, "Type", { enumerable: true, get: function () { return types_3.Type; } });

Object.defineProperty(exports, "IntersectionType", { enumerable: true, get: function () { return types_3.IntersectionType; } });
const keySignature = Symbol('keySignature');
exports.keySignature = keySignature;
const string = (opts) => new types_2.StringType(opts);

@@ -49,9 +48,9 @@ exports.string = string;

exports.literals = literals;
const record = (schema) => new types_2.ObjectType({ [keySignature]: schema });
const record = (schema) => new types_2.ObjectType({ [types_2.keySignature]: schema });
exports.record = record;
const dictionary = (schema) => {
if (schema instanceof types_2.OptionalType) {
return new types_2.ObjectType({ [keySignature]: schema });
return new types_2.ObjectType({ [types_2.keySignature]: schema });
}
return new types_2.ObjectType({ [keySignature]: new types_2.OptionalType(schema) });
return new types_2.ObjectType({ [types_2.keySignature]: new types_2.OptionalType(schema) });
};

@@ -113,3 +112,3 @@ exports.dictionary = dictionary;

ValidationError: types_2.ValidationError,
keySignature: keySignature,
keySignature: types_2.keySignature,
// types

@@ -116,0 +115,0 @@ NumberType: types_2.NumberType,

@@ -1,2 +0,3 @@

import { keySignature } from './index';
declare const keySignature: unique symbol;
export { keySignature };
declare const typeErrSym: unique symbol;

@@ -404,2 +405,1 @@ declare const coercionTypeSymbol: unique symbol;

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LazyType = exports.PartialType = exports.EnumType = exports.IntersectionType = exports.UnionType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.DateType = exports.NullableType = exports.OptionalType = exports.UnknownType = exports.LiteralType = exports.NullType = exports.UndefinedType = exports.BigIntType = exports.NumberType = exports.BooleanType = exports.StringType = exports.ValidationError = exports.Type = void 0;
const index_1 = require("./index");
function clone(value) {
if (typeof value !== 'object' || value === null) {
return value;
}
if (Array.isArray(value)) {
return value.map(elem => clone(elem));
}
const cpy = Object.create(null);
for (const k in value) {
cpy[k] = clone(value[k]);
}
for (const s of Object.getOwnPropertySymbols(value)) {
cpy[s] = clone(value[s]);
}
Object.setPrototypeOf(cpy, Object.getPrototypeOf(value));
return cpy;
exports.LazyType = exports.PartialType = exports.EnumType = exports.IntersectionType = exports.UnionType = exports.TupleType = exports.ArrayType = exports.ObjectType = exports.DateType = exports.NullableType = exports.OptionalType = exports.UnknownType = exports.LiteralType = exports.NullType = exports.UndefinedType = exports.BigIntType = exports.NumberType = exports.BooleanType = exports.StringType = exports.ValidationError = exports.Type = exports.keySignature = void 0;
const keySignature = Symbol('keySignature');
exports.keySignature = keySignature;
function shallowClone(value) {
// create a new object with the same prototype then copy all enumerable own properties
return Object.assign(Object.create(Object.getPrototypeOf(value)), value);
}

@@ -31,3 +19,3 @@ const typeErrSym = Symbol('typeError');

if (this instanceof OptionalType) {
return clone(this);
return shallowClone(this);
}

@@ -38,3 +26,3 @@ return new OptionalType(this);

if (this instanceof NullableType) {
return clone(this);
return shallowClone(this);
}

@@ -55,3 +43,3 @@ return new NullableType(this);

onTypeError(msg) {
const cpy = clone(this);
const cpy = shallowClone(this);
cpy[typeErrSym] = msg;

@@ -196,3 +184,3 @@ return cpy;

const withPredicate = (schema, predicate) => {
const cpy = clone(schema);
const cpy = shallowClone(schema);
cpy.predicates = appendPredicate(cpy.predicates, predicate);

@@ -202,3 +190,3 @@ return cpy;

const withDefault = (schema, value) => {
const cpy = clone(schema);
const cpy = shallowClone(schema);
cpy[coercionTypeSymbol] = true;

@@ -459,3 +447,3 @@ cpy.defaultValue = value;

required() {
return clone(this.schema);
return shallowClone(this.schema);
}

@@ -487,3 +475,3 @@ and(schema) {

required() {
return clone(this.schema);
return shallowClone(this.schema);
}

@@ -541,3 +529,3 @@ default(value) {

const keys = Object.keys(this.objectShape);
this[index_1.keySignature] = this.objectShape[index_1.keySignature];
this[keySignature] = this.objectShape[keySignature];
this[allowUnknownSymbol] = (opts === null || opts === void 0 ? void 0 : opts.allowUnknown) === true;

@@ -549,3 +537,3 @@ this[shapekeysSymbol] = keys;

Object.values(this.objectShape).some(schema => schema[coercionTypeSymbol]) ||
!!(this.objectShape[index_1.keySignature] && this.objectShape[index_1.keySignature][coercionTypeSymbol]);
!!(this.objectShape[keySignature] && this.objectShape[keySignature][coercionTypeSymbol]);
this._parse = this.selectParser();

@@ -559,3 +547,3 @@ }

const allowUnknown = parseOpts.allowUnknown || this[allowUnknownSymbol];
if (!allowUnknown && !this.objectShape[index_1.keySignature]) {
if (!allowUnknown && !this.objectShape[keySignature]) {
const illegalKeys = [];

@@ -581,3 +569,3 @@ for (const k in value) {

selectParser() {
if (this[shapekeysSymbol].length === 0 && this[index_1.keySignature]) {
if (this[shapekeysSymbol].length === 0 && this[keySignature]) {
if (this[coercionTypeSymbol] && this.shouldCollectErrors) {

@@ -594,3 +582,3 @@ return this.parseRecordConvCollect;

}
if (this[index_1.keySignature]) {
if (this[keySignature]) {
if (this[coercionTypeSymbol] && this.shouldCollectErrors) {

@@ -710,3 +698,3 @@ return this.parseMixRecordConvCollect;

try {
this[index_1.keySignature].parse(value[key], { suppressPathErrMsg: true });
this[keySignature].parse(value[key], { suppressPathErrMsg: true });
}

@@ -726,3 +714,3 @@ catch (err) {

for (const key in value) {
const result = this[index_1.keySignature].try(value[key], { suppressPathErrMsg: true });
const result = this[keySignature].try(value[key], { suppressPathErrMsg: true });
if (result instanceof ValidationError) {

@@ -745,3 +733,3 @@ hasError = true;

try {
convVal[key] = this[index_1.keySignature].parse(value[key], { suppressPathErrMsg: true });
convVal[key] = this[keySignature].parse(value[key], { suppressPathErrMsg: true });
}

@@ -762,3 +750,3 @@ catch (err) {

for (const key in value) {
const result = this[index_1.keySignature].try(value[key], { suppressPathErrMsg: true });
const result = this[keySignature].try(value[key], { suppressPathErrMsg: true });
if (result instanceof ValidationError) {

@@ -783,3 +771,3 @@ hasError = true;

try {
(this.objectShape[key] || this[index_1.keySignature]).parse(value[key], { suppressPathErrMsg: true });
(this.objectShape[key] || this[keySignature]).parse(value[key], { suppressPathErrMsg: true });
}

@@ -799,3 +787,3 @@ catch (err) {

for (const key of new Set(Object.keys(value).concat(this[shapekeysSymbol]))) {
const result = (this.objectShape[key] || this[index_1.keySignature]).try(value[key], {
const result = (this.objectShape[key] || this[keySignature]).try(value[key], {
suppressPathErrMsg: true,

@@ -820,3 +808,3 @@ });

try {
convVal[key] = (this.objectShape[key] || this[index_1.keySignature]).parse(value[key], {
convVal[key] = (this.objectShape[key] || this[keySignature]).parse(value[key], {
suppressPathErrMsg: true,

@@ -839,3 +827,3 @@ });

for (const key of new Set(Object.keys(value).concat(this[shapekeysSymbol]))) {
const result = (this.objectShape[key] || this[index_1.keySignature]).try(value[key], {
const result = (this.objectShape[key] || this[keySignature]).try(value[key], {
suppressPathErrMsg: true,

@@ -874,9 +862,9 @@ });

}, {});
const selfKeySig = this.objectShape[index_1.keySignature];
const targetKeySig = schema[index_1.keySignature];
const selfKeySig = this.objectShape[keySignature];
const targetKeySig = schema[keySignature];
if (selfKeySig && targetKeySig) {
intersectShape[index_1.keySignature] = selfKeySig.and(targetKeySig);
intersectShape[keySignature] = selfKeySig.and(targetKeySig);
}
else if (selfKeySig || targetKeySig) {
intersectShape[index_1.keySignature] = selfKeySig || targetKeySig;
intersectShape[keySignature] = selfKeySig || targetKeySig;
}

@@ -889,4 +877,4 @@ return new ObjectType(intersectShape);

const pickedShape = keys.reduce((acc, key) => {
if (this.objectShape[key] || this.objectShape[index_1.keySignature]) {
acc[key] = this.objectShape[key] || this.objectShape[index_1.keySignature];
if (this.objectShape[key] || this.objectShape[keySignature]) {
acc[key] = this.objectShape[key] || this.objectShape[keySignature];
}

@@ -899,6 +887,6 @@ return acc;

const pickedKeys = this[shapekeysSymbol].filter((x) => !keys.includes(x));
if (!this[index_1.keySignature]) {
if (!this[keySignature]) {
return this.pick(pickedKeys, opts);
}
return this.pick(pickedKeys, opts).and(new ObjectType({ [index_1.keySignature]: this[index_1.keySignature] }));
return this.pick(pickedKeys, opts).and(new ObjectType({ [keySignature]: this[keySignature] }));
}

@@ -916,9 +904,9 @@ partial(opts) {

}, {});
const keysig = originalShape[index_1.keySignature];
const keysig = originalShape[keySignature];
if (keysig) {
if (opts === null || opts === void 0 ? void 0 : opts.deep) {
shape[index_1.keySignature] = toPartialSchema(keysig, opts).optional();
shape[keySignature] = toPartialSchema(keysig, opts).optional();
}
else {
shape[index_1.keySignature] = keysig.optional();
shape[keySignature] = keysig.optional();
}

@@ -941,3 +929,3 @@ }

collectErrors(value = true) {
const cpy = clone(this);
const cpy = shallowClone(this);
cpy.shouldCollectErrors = value;

@@ -948,3 +936,3 @@ cpy._parse = cpy.selectParser();

allowUnknownKeys(value = true) {
const cpy = clone(this);
const cpy = shallowClone(this);
cpy[allowUnknownSymbol] = value;

@@ -951,0 +939,0 @@ cpy[coercionTypeSymbol] = cpy[coercionTypeSymbol] || value;

{
"name": "myzod",
"version": "1.11.0",
"version": "1.12.0",
"description": "",

@@ -8,3 +8,3 @@ "main": "./libs/index.js",

"scripts": {
"test": "nyc mocha \"test/**/*test.ts\"",
"test": "mocha \"test/**/*test.ts\"",
"build": "rm -rf ./libs && tsc",

@@ -11,0 +11,0 @@ "pub": "npm t && npm run build && npm publish",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc