superstruct
Advanced tools
Comparing version 2.0.0-0 to 2.0.0
@@ -38,3 +38,4 @@ import { StructSchema } from './utils.js'; | ||
* Mask a value, coercing and validating it, but returning only the subset of | ||
* properties defined by the struct's schema. | ||
* properties defined by the struct's schema. Masking applies recursively to | ||
* props of `object` structs only. | ||
*/ | ||
@@ -46,8 +47,10 @@ mask(value: unknown, message?: string): T; | ||
* | ||
* You may optionally pass `true` for the `withCoercion` argument to coerce | ||
* You may optionally pass `true` for the `coerce` argument to coerce | ||
* the value before attempting to validate it. If you do, the result will | ||
* contain the coerced result when successful. | ||
* contain the coerced result when successful. Also, `mask` will turn on | ||
* masking of the unknown `object` props recursively if passed. | ||
*/ | ||
validate(value: unknown, options?: { | ||
coerce?: boolean; | ||
mask?: boolean; | ||
message?: string; | ||
@@ -83,3 +86,6 @@ }): [StructError, undefined] | [undefined, T]; | ||
* A `Context` contains information about the current location of the | ||
* validation inside the initial input value. | ||
* validation inside the initial input value. It also carries `mask` | ||
* since it's a run-time flag determining how the validation was invoked | ||
* (via `mask()` or via `validate()`), plus it applies recursively | ||
* to all of the nested structs. | ||
*/ | ||
@@ -89,2 +95,3 @@ export type Context = { | ||
path: Array<any>; | ||
mask?: boolean; | ||
}; | ||
@@ -91,0 +98,0 @@ /** |
@@ -8,2 +8,6 @@ import { Struct, Infer, Result, Context, Describe } from './struct.js'; | ||
/** | ||
* Check if a value is a non-array object. | ||
*/ | ||
export declare function isNonArrayObject(x: unknown): x is object; | ||
/** | ||
* Check if a value is a plain object. | ||
@@ -10,0 +14,0 @@ */ |
{ | ||
"name": "superstruct", | ||
"description": "A simple and composable way to validate data in JavaScript (and TypeScript).", | ||
"version": "2.0.0-0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -19,3 +19,3 @@ "repository": "git://github.com/ianstormtaylor/superstruct.git", | ||
"engines": { | ||
"node": ">=18.0.0" | ||
"node": ">=14.0.0" | ||
}, | ||
@@ -38,5 +38,2 @@ "devDependencies": { | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"is-email": "^1.0.0", | ||
"is-url": "^1.2.4", | ||
"is-uuid": "^1.0.2", | ||
"lodash": "^4.17.15", | ||
@@ -43,0 +40,0 @@ "np": "^10.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
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
181636
21
2657
1