Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ow

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ow - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

dist/source/argument-error.d.ts

27

package.json
{
"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 @@

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