Comparing version 0.12.0 to 0.13.0
{ | ||
"name": "ow", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "Function argument validation for humans", | ||
@@ -12,3 +12,3 @@ "license": "MIT", | ||
}, | ||
"main": "dist/index.js", | ||
"main": "dist/source", | ||
"engines": { | ||
@@ -28,3 +28,3 @@ "node": ">=6" | ||
"files": [ | ||
"dist" | ||
"dist/source" | ||
], | ||
@@ -52,9 +52,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"@sindresorhus/is": "^0.14.0", | ||
"@sindresorhus/tsconfig": "^0.2.0", | ||
"@types/dot-prop": "^4.2.0", | ||
"@sindresorhus/is": "^0.16.0", | ||
"@sindresorhus/tsconfig": "^0.3.0", | ||
"@types/lodash.isequal": "^4.5.2", | ||
"@types/node": "^10.12.21", | ||
"@types/node": "^12.0.0", | ||
"@types/vali-date": "^1.0.0", | ||
"add-module-exports-webpack-plugin": "^0.1.0", | ||
"add-module-exports-webpack-plugin": "^1.0.0", | ||
"ava": "^1.0.1", | ||
@@ -65,8 +64,9 @@ "awesome-typescript-loader": "^5.2.1", | ||
"del-cli": "^1.1.0", | ||
"dot-prop": "^4.2.0", | ||
"dot-prop": "^5.0.0", | ||
"license-webpack-plugin": "^2.0.2", | ||
"lodash.isequal": "^4.5.0", | ||
"nyc": "^13.1.0", | ||
"nyc": "^14.1.1", | ||
"tslint": "^5.12.0", | ||
"tslint-xo": "^0.13.0", | ||
"tslint-xo": "^0.16.0", | ||
"type-fest": "^0.4.1", | ||
"typedoc": "^0.14.2", | ||
@@ -78,3 +78,6 @@ "typescript": "^3.3.1", | ||
}, | ||
"typings": "dist/index.d.ts", | ||
"browser": { | ||
"./dist/source/utils/infer-label.js": "./dist/source/utils/infer-label.browser.js" | ||
}, | ||
"types": "dist", | ||
"sideEffects": false, | ||
@@ -81,0 +84,0 @@ "ava": { |
@@ -217,3 +217,27 @@ <p align="center"> | ||
#### validate(fn) | ||
Use a custom validation object. The difference with `is` is that the function should return a validation object, which allows more flexibility. | ||
```ts | ||
ow(1, ow.number.validate(value => ({ | ||
validator: value > 10, | ||
message: `Expected value to be greater than 10, got ${x}` | ||
}))); | ||
//=> ArgumentError: (number) Expected value to be greater than 10, got 1 | ||
``` | ||
You can also pass in a function as `message` value which accepts the label as argument. | ||
```ts | ||
ow(1, 'input', ow.number.validate(value => ({ | ||
validator: x > 10, | ||
message: label => `Expected ${label} to be greater than 10, got ${x}` | ||
}))); | ||
//=> ArgumentError: Expected number `input` to be greater than 10, got 1 | ||
``` | ||
This can be useful for creating your own reusable validators which can be extracted to a separate npm package. | ||
## Maintainers | ||
@@ -220,0 +244,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
282053
257
33
1133
2