walli schema to walli
See walli
npm install walli-schema
# or use yarn
yarn add walli-schema
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
})
- 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 :)
This library is written and maintained by imcuttle, moyuyc95@gmail.com.
MIT - imcuttle 🐟