@seanwarman/json-form-builder

0.0.4 • Public • Published

Json Builder

A tool to create json type components for quick and standardised input forms.

Choose the type of builder you want:

const jsonFormBuilder = JsonBuilder('jsonForm');

Then add an array of field types to quickly construct the json object. Adding title-cases to the fields you want to be required:

let jsonForm = jsonFormBuilder(['input', 'Input', 'textarea']);

// jsonForm = [ 
//   { type: 'input',
//     label: '',
//     value: '',
//     required: false,
//     prettyType: 'Text' },
//   { type: 'input',
//     label: '',
//     value: '',
//     required: true,
//     prettyType: 'Text' },
//   { type: 'textarea',
//     label: '',
//     value: '',
//     required: false,
//     prettyType: 'Long Text' } 
// ]

Sanitising

There's also some sanitising tools that come with the builder:

const jsonFormSanitiser = JsonFormBuilder('jsonFormSanitiser');

This will sanitise all values of the jsonForm then convert the whole object to a string ready to go to a MYSQL database.

const data {
    jsonForm: jsonFormSanitiser(jsonForm);
}

The other tools included are:

  • sanitiseValues(Json) - this will sanitise the values without converting the object to a string.
  • sanitiseString(String) - this will simply sanitise any string.

Readme

Keywords

Package Sidebar

Install

npm i @seanwarman/json-form-builder

Weekly Downloads

1

Version

0.0.4

License

ISC

Unpacked Size

8.19 kB

Total Files

4

Last publish

Collaborators

  • seanwarman