Skip to content

Useful, powerful and simple object validation based on a schema object with rules that can be glob pattern, regexp, string, array, function or dot property paths like `a.b.c` for nested objects.

License

tunnckoCore/thron

Repository files navigation

Useful, powerful and simple object validation based on a schema object with rules that can be glob pattern, regexp, string, array, function or dot property paths like a.b.c for nested objects.

code climate standard code style travis build status coverage status dependency status

Install

npm i thron --save
npm test

Usage

For more use-cases see the tests

var schema = require('thron')
var validate = schema({
  name: 'foo*',
  username: ['jonschlin*', 'tunncko*'],
  info: function (val) {
    return typeof val === 'string' && val.indexOf('qux') !== -1
  },
  'user.age': /\d{5}/g,
  'user.name': 'Charlike'
})
var result = validate({
  name: 'foobar',
  username: 'tunnckoCore',
  info: 'foo bar baz',
  user: {
    age: 22,
    name: 'Jon'
  }
})

console.log(result)
//=> { name: 'foobar', username: 'tunnckoCore' }

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github

About

Useful, powerful and simple object validation based on a schema object with rules that can be glob pattern, regexp, string, array, function or dot property paths like `a.b.c` for nested objects.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published