dynamic-forms-json-schema
v1.2.2
Published
A library to dynamically generate and validate forms based on a JSON schema.
Downloads
3
Readme
dynamic-forms-json-schema
A library for generating dynamic forms based on JSON Schema.
Installation
You can install this library via npm:
npm install dynamic-forms-json-schema
Usage
const DynamicForm = require('dynamic-forms-json-schema');
// Define your JSON schema
const schema = {
type: 'object',
properties: {
// Define your form properties here
},
required: [],
additionalProperties: false,
};
// Create a new instance of DynamicForm
const dynamicForm = new DynamicForm(schema);
// Validate form data
const formData = {
// Provide your form data here
};
if (dynamicForm.validateFormData(formData)) {
console.log('Form data is valid!');
} else {
console.error('Form data is invalid.');
}
// Generate a unique form ID
const formId = dynamicForm.generateFormId();
console.log('Form ID:', formId);
License
This project is licensed under the MIT License - see the LICENSE file for details.