@dztek/truth
v1.0.0-prerelease-k
Published
Logic and validation framework
Downloads
14
Readme
@dztek/truth
Logic and validation framework
Prerelease:
This package may cause cause breaking changes or may break from time to time while the package format is being determined.
Open source git repo will be share via Gitlab soon. Contributors welcome.
Note:
You must create or import your own validation logic to make queries with the framework
Why?
Truth is a framework that makes any "truth evaluating" source queriable with text
Example:
Setup:
const { Validator } = require('@dztek/truth')
const luhn = require('luhn')
const validator = require('validator')
const rulePacks = [
{ definitions: { isCreditCard: luhn.validate } },
{ definitions: { isEmail: validator.isEmail }, ns: 'v' }
]
Use:
const truth = new Validator({ rulePacks })
truth.validate('4111111111111111', 'isCreditCard')
// works with namespace set above
truth.validate('[email protected]', 'v:isEmail')