Browse Source

Minor tweaks

iss58
Sindre Sorhus 7 years ago
parent
commit
48f849ec81
  1. 26
      example.js
  2. 2
      package.json
  3. 12
      readme.md

26
example.js

@ -1,18 +1,22 @@
'use strict'; 'use strict';
const ow = require('./dist'); const ow = require('./dist');
const fn = (input, options) => { const logError = fn => {
ow(input, ow.string.minLength(10)); try {
fn();
} catch (err) {
console.log(err.message);
}
};
// For objects, just an idea for now: const fn = input => {
// ow.many(options, { ow(input, ow.string.minLength(10));
// tasks: ow.number.range(0, 10),
// extras: ow.arrayOf(ow.number)
// });
}; };
//fn(10); logError(() => {
//=> ArgumentError: Expected argument to be of type `string` but received type `number` fn(10);
});
fn('foo'); logError(() => {
//=> ArgumentError: Expected string length to be minimum 10 fn('foo');
});

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "ow", "name": "ow",
"version": "0.2.0", "version": "0.2.0",
"description": "Argument type validation", "description": "Function argument validation for humans",
"license": "MIT", "license": "MIT",
"repository": "sindresorhus/ow", "repository": "sindresorhus/ow",
"author": { "author": {

12
readme.md

@ -6,9 +6,15 @@
[![Build Status](https://travis-ci.org/sindresorhus/ow.svg?branch=master)](https://travis-ci.org/sindresorhus/ow) [![Coverage Status](https://codecov.io/gh/sindresorhus/ow/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/ow) [![Build Status](https://travis-ci.org/sindresorhus/ow.svg?branch=master)](https://travis-ci.org/sindresorhus/ow) [![Coverage Status](https://codecov.io/gh/sindresorhus/ow/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/ow)
> Argument type validation > Function argument validation for humans
[View documentation](https://sindresorhus.com/ow)
## Highlights
- Expressive chainable API
- Lots of built-in validations
- Supports custom validations
- Written in TypeScript
## Install ## Install
@ -39,6 +45,8 @@ unicorn('yo');
## API ## API
[Complete API documentation](https://sindresorhus.com/ow)
### ow(value, predicate) ### ow(value, predicate)
Test if `value` matches the provided `predicate`. Test if `value` matches the provided `predicate`.

Loading…
Cancel
Save