walli-schema
v1.0.3
Published
walli schema to walli
Downloads
2
Maintainers
Readme
walli-schema
walli schema to walli
See walli
Installation
npm install walli-schema
# or use yarn
yarn add walli-schema
Usage
import { schemaToWalli, createSchemaToWalli } from 'walli-schema'
const verifiable = schemaToWalli({
$type: 'every',
rule: [
{
$type: 'leq',
rule: {
a: 1
}
},
{
$type: 'oneOf',
rule: [
{
$type: 'leq',
rule: {
b: 2,
c: 3
}
},
{
$type: 'leq',
rule: {
b: 3,
c: 2
}
}
]
}
]
})
// => equals
walli.every([
walli.leq({ a: 1 }),
walli.oneOf([
walli.leq({b: 2, c: 3}),
walli.leq({b: 3, c: 2}),
]),
])
expect(
verifiable.ok({
a: 1
})
).toBeFalsy()
expect(
verifiable.ok({
a: 1,
b: 2
})
).toBeFalsy()
//
expect(
verifiable.ok({
a: 1,
b: 2,
c: 3
})
).toBeTruthy()
expect(
verifiable.ok({
a: 1,
b: 3,
c: 2
})
).toBeTruthy()
const customSchemaToWalli = createSchemaToWalli({
string: walli.string
// custom... $types
})
Contributing
- Fork it!
- Create your new branch:
git checkout -b feature-new
orgit checkout -b fix-which-bug
- Start your magic work now
- Make sure npm test passes
- Commit your changes:
git commit -am 'feat: some description (close #123)'
orgit commit -am 'fix: some description (fix #123)'
- Push to the branch:
git push
- Submit a pull request :)
Authors
This library is written and maintained by imcuttle, [email protected].
License
MIT - imcuttle 🐟