superstruct
Advanced tools
Comparing version 0.16.7 to 1.0.0
@@ -10,2 +10,3 @@ /** | ||
message: string; | ||
explanation?: string; | ||
branch: Array<any>; | ||
@@ -12,0 +13,0 @@ path: Array<any>; |
@@ -27,7 +27,7 @@ import { StructSchema } from './utils'; | ||
*/ | ||
assert(value: unknown): asserts value is T; | ||
assert(value: unknown, message?: string): asserts value is T; | ||
/** | ||
* Create a value with the struct's coercion logic, then validate it. | ||
*/ | ||
create(value: unknown): T; | ||
create(value: unknown, message?: string): T; | ||
/** | ||
@@ -41,3 +41,3 @@ * Check if a value passes the struct's validation. | ||
*/ | ||
mask(value: unknown): T; | ||
mask(value: unknown, message?: string): T; | ||
/** | ||
@@ -53,2 +53,3 @@ * Validate a value with the struct's validation logic, returning a tuple | ||
coerce?: boolean; | ||
message?: string; | ||
}): [StructError, undefined] | [undefined, T]; | ||
@@ -59,11 +60,11 @@ } | ||
*/ | ||
export declare function assert<T, S>(value: unknown, struct: Struct<T, S>): asserts value is T; | ||
export declare function assert<T, S>(value: unknown, struct: Struct<T, S>, message?: string): asserts value is T; | ||
/** | ||
* Create a value with the coercion logic of struct and validate it. | ||
*/ | ||
export declare function create<T, S>(value: unknown, struct: Struct<T, S>): T; | ||
export declare function create<T, S>(value: unknown, struct: Struct<T, S>, message?: string): T; | ||
/** | ||
* Mask a value, returning only the subset of properties defined by a struct. | ||
*/ | ||
export declare function mask<T, S>(value: unknown, struct: Struct<T, S>): T; | ||
export declare function mask<T, S>(value: unknown, struct: Struct<T, S>, message?: string): T; | ||
/** | ||
@@ -80,2 +81,3 @@ * Check if a value passes a struct. | ||
mask?: boolean; | ||
message?: string; | ||
}): [StructError, undefined] | [undefined, T]; | ||
@@ -82,0 +84,0 @@ /** |
@@ -39,2 +39,3 @@ import { Struct, Infer, Result, Context, Describe } from './struct'; | ||
mask?: boolean; | ||
message?: string; | ||
}): IterableIterator<[Failure, undefined] | [undefined, T]>; | ||
@@ -52,3 +53,3 @@ /** | ||
*/ | ||
export declare type EnumSchema<T extends string | number | undefined> = { | ||
export declare type EnumSchema<T extends string | number | undefined | null> = { | ||
[K in NonNullable<T>]: K; | ||
@@ -119,3 +120,3 @@ }; | ||
*/ | ||
export declare type StructSchema<T> = [T] extends [string | undefined] ? [T] extends [IsMatch<T, string | undefined>] ? null : [T] extends [IsUnion<T>] ? EnumSchema<T> : T : [T] extends [number | undefined] ? [T] extends [IsMatch<T, number | undefined>] ? null : [T] extends [IsUnion<T>] ? EnumSchema<T> : T : [T] extends [boolean] ? [T] extends [IsExactMatch<T, boolean>] ? null : T : T extends bigint | symbol | undefined | null | Function | Date | Error | RegExp | Map<any, any> | WeakMap<any, any> | Set<any> | WeakSet<any> | Promise<any> ? null : T extends Array<infer E> ? T extends IsTuple<T> ? null : Struct<E> : T extends object ? T extends IsRecord<T> ? null : { | ||
export declare type StructSchema<T> = [T] extends [string | undefined | null] ? [T] extends [IsMatch<T, string | undefined | null>] ? null : [T] extends [IsUnion<T>] ? EnumSchema<T> : T : [T] extends [number | undefined | null] ? [T] extends [IsMatch<T, number | undefined | null>] ? null : [T] extends [IsUnion<T>] ? EnumSchema<T> : T : [T] extends [boolean] ? [T] extends [IsExactMatch<T, boolean>] ? null : T : T extends bigint | symbol | undefined | null | Function | Date | Error | RegExp | Map<any, any> | WeakMap<any, any> | Set<any> | WeakSet<any> | Promise<any> ? null : T extends Array<infer E> ? T extends IsTuple<T> ? null : Struct<E> : T extends object ? T extends IsRecord<T> ? null : { | ||
[K in keyof T]: Describe<T[K]>; | ||
@@ -122,0 +123,0 @@ } : null; |
@@ -5,21 +5,22 @@ { | ||
"description": "A simple and composable way to validate data in JavaScript (and TypeScript).", | ||
"version": "0.16.7", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"repository": "git://github.com/ianstormtaylor/superstruct.git", | ||
"source": "./src/index.ts", | ||
"types": "./lib/index.d.ts", | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.mjs", | ||
"exports": { | ||
"import": "./lib/index.mjs", | ||
"require": "./lib/index.cjs" | ||
}, | ||
"sideEffects": false, | ||
"files": [ | ||
"umd", | ||
"lib" | ||
], | ||
"exports": { | ||
".": { | ||
"import": "./vite/superstruct.js", | ||
"require": "./vite/superstruct.cjs", | ||
"types": "./lib/index.d.ts" | ||
} | ||
}, | ||
"publishConfig": { | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -29,11 +30,12 @@ "@babel/cli": "^7.6.3", | ||
"@babel/plugin-transform-modules-commonjs": "^7.12.1", | ||
"@babel/preset-env": "^7.6.3", | ||
"@babel/preset-env": "^7.20.2", | ||
"@babel/preset-typescript": "^7.6.0", | ||
"@babel/register": "^7.6.2", | ||
"@rollup/plugin-typescript": "^9.0.2", | ||
"@types/expect": "^24.3.0", | ||
"@types/lodash": "^4.14.144", | ||
"@types/mocha": "^9.1.1", | ||
"@types/mocha": "^10.0.0", | ||
"@types/node": "^18.7.14", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"@typescript-eslint/eslint-plugin": "^5.43.0", | ||
"@typescript-eslint/parser": "^5.43.0", | ||
"babel-eslint": "^10.0.3", | ||
@@ -49,33 +51,21 @@ "eslint": "^7.14.0", | ||
"mocha": "^10.0.0", | ||
"np": "^7.0.0", | ||
"np": "^7.6.2", | ||
"prettier": "^2.0.5", | ||
"rollup": "^2.12.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-ts": "^3.0.1", | ||
"rollup": "^3.3.0", | ||
"typescript": "^4.8.3" | ||
}, | ||
"scripts": { | ||
"build": "rm -rf ./{lib,umd} && yarn build:types && yarn build:mjs && yarn build:cjs && yarn build:umd && yarn build:umd-min", | ||
"build:cjs": "rollup --config ./config/rollup-cjs.js", | ||
"build:mjs": "rollup --config ./config/rollup.js", | ||
"build:umd": "rollup --config ./config/rollup-umd.js", | ||
"build:umd-min": "rollup --config ./config/rollup-umd-min.js", | ||
"build:types": "tsc --emitDeclarationOnly --declarationMap --outDir ./lib", | ||
"clean": "rm -rf ./{lib,umd,node_modules}", | ||
"fix": "yarn fix:eslint && yarn fix:prettier", | ||
"fix:eslint": "yarn lint:eslint --fix", | ||
"fix:prettier": "yarn lint:prettier --write", | ||
"lint": "yarn lint:eslint && yarn lint:prettier", | ||
"build": "rm -rf ./{lib} && rollup --config ./rollup.config.js", | ||
"clean": "rm -rf ./{lib,node_modules}", | ||
"fix": "npm run fix:eslint && npm run fix:prettier", | ||
"fix:eslint": "npm run lint:eslint --fix", | ||
"fix:prettier": "npm run lint:prettier --write", | ||
"lint": "npm run lint:eslint && npm run lint:prettier", | ||
"lint:eslint": "eslint '{src,test}/*.{js,ts}'", | ||
"lint:prettier": "prettier --list-different '**/*.{js,json,ts}'", | ||
"release": "yarn build && yarn lint && np", | ||
"test": "yarn build:types && yarn test:types && yarn build:cjs && yarn test:mocha", | ||
"release": "npm run build && npm run lint && np", | ||
"test": "npm run build && npm run test:types && npm run test:mocha", | ||
"test:mocha": "mocha --require ./test/register.cjs --require source-map-support/register ./test/index.ts", | ||
"test:types": "tsc --noEmit && tsc --project ./test/tsconfig.json --noEmit", | ||
"watch": "yarn build:cjs --watch", | ||
"watch:types": "yarn build:types --watch" | ||
"watch": "npm run build -- --watch" | ||
}, | ||
@@ -112,7 +102,3 @@ "keywords": [ | ||
"validator" | ||
], | ||
"dependencies": {}, | ||
"engines": { | ||
"node": ">=14.0.0" | ||
} | ||
] | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
27
1
173951
23
2589