diff --git a/example.js b/example.js index 27a6036..46da31a 100644 --- a/example.js +++ b/example.js @@ -1,18 +1,22 @@ 'use strict'; const ow = require('./dist'); -const fn = (input, options) => { - ow(input, ow.string.minLength(10)); +const logError = fn => { + try { + fn(); + } catch (err) { + console.log(err.message); + } +}; - // For objects, just an idea for now: - // ow.many(options, { - // tasks: ow.number.range(0, 10), - // extras: ow.arrayOf(ow.number) - // }); +const fn = input => { + ow(input, ow.string.minLength(10)); }; -//fn(10); -//=> ArgumentError: Expected argument to be of type `string` but received type `number` +logError(() => { + fn(10); +}); -fn('foo'); -//=> ArgumentError: Expected string length to be minimum 10 +logError(() => { + fn('foo'); +}); diff --git a/package.json b/package.json index 9621030..888b6fc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ow", "version": "0.2.0", - "description": "Argument type validation", + "description": "Function argument validation for humans", "license": "MIT", "repository": "sindresorhus/ow", "author": { diff --git a/readme.md b/readme.md index 4c8d045..1cb1ac3 100644 --- a/readme.md +++ b/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) -> 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 @@ -39,6 +45,8 @@ unicorn('yo'); ## API +[Complete API documentation](https://sindresorhus.com/ow) + ### ow(value, predicate) Test if `value` matches the provided `predicate`.