Package Exports
- @kravc/schema
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@kravc/schema) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@kravc/schema
Advanced JSON schema manipulation and validation library based on z-schema.
API
Install:
npm i --save @kravc/schemaGet started
const { Schema, Validator } = require('@kravc/schema')
const baseSchema = new Schema({ name: { required: true } }, 'Base')
const profileSchema = baseSchema
.extend({
status: {
enum: [ 'Pending', 'Active' ],
default: 'Pending'
}
}, 'Profile')
const validator = new Validator([ profileSchema ])
const profile = validator.validate({ name: 'John' }, 'Profile')
console.log(profile)Expected output:
{ name: 'John', status: 'Pending' }