jyon
v0.0.0
Published
Work in progress.
Downloads
67
Readme
Work in progress.
What problem does jyon solve?
- Builder pattern: A builder pattern validation that is fundamentally a JSON schema
- Modifiable/extendable: Add more JSON-types with custom errors.
- JSON-schema instantiation: Can be instantiated via a raw JSON-schema or using jyon builder pattern
import { JYON } from 'jyon'
import forms from 'jyon/forms' // Validators suited for forms
import json7 from 'jyon/json7' // Validators based on JSON7 schema
const y = new JYON({
validators: [...]
})
// or import default
import y from 'jyon'
export default y
import y from '$jyon'
const user = y.object({
id: y.string(),
name: y.string()
})
await user.validate(data, opts)
await user.partial().validate(data, opts)
await user.deepPartial().validate(data, opts)
// Access it like a JSON-schema
user.properties.name.validate('dis is string?')
console.log(user) // outputs JSON-schema structure