abides

1.1.2 • Public • Published

the dude

Build Status codecov Maintainability

abides

modern javascript object validation.
validate, default and transform data.

not production ready yet, use at own risk.

  • lightweight (~1kb min+gzipped bundled)
  • only 3 deps (lodash, esm and fromentries polyfill)
  • non-obscure control of validation

example

import { abides, ofType, numberCoerce } from 'abides'
 
abides(5, ofType(Number))
// => { ok: true, errors: [], self: { error: '' }, result: 5 }
abides('5', ofType(Number))
/* => {
  ok: false,
  self: { error: 'is '5' but should be of type Number' },
  errors: ['is '5' but should be of type Number'],
  result: '5'
*/
abides('5', [numberCoerce, ofType(Number)])
// => { ok: true, errors: [], self: { error: null }, result: 5 }

more examples

install

yarn add abides
or npm
npm i --save abides

planned changes

  • validator caching
  • async support
  • web forms ready errors
  • typescript implementation

requirements

  • ES2017 (as in, node 8, a modern browser or a babel like library)

other docs

open to contributions

help is needed in:

  • typescript definition and type check tests.

Readme

Keywords

Package Sidebar

Install

npm i abides

Weekly Downloads

1

Version

1.1.2

License

MIT

Unpacked Size

37.8 kB

Total Files

77

Last publish

Collaborators

  • gtarsia