@pratico/json-schema-forms
v0.1.2
Published
This package allow you to connect HTML5 Forms with json-schema validation
Downloads
1
Readme
@pratico/json-schema-forms
Connects HTML Forms to Json Schemas, which provide a nice validation strategy which would be integrated / shared with the backend also.
Usage:
import * as ajv from 'ajv';
import { FormConnector } from '@pratico/json-schema-forms';
import { Validator } from '@pratico/json-schema';
let form = window.document.getElementsByTagName('form')[0];
const connector = new FormConnector({
formElement: form,
jsonSchema: {
required: ['summary'],
properties: {
summary: {
type: 'string',
minLength: 2
}
}
},
validateOnChange: true,
praticoValidator: new Validator(
{
schemas: []
},
ajv
)
});
connector.onValidated((result: any) => {
console.log(result);
});