formscript-schema

0.0.5 • Public • Published

formscript-schema

Known Vulnerabilities

Contains a JSON Schema for Formscript, along with a validation utility.

Install

$ npm install formscript-schema --save

Usage

const formscriptSchema = require('formscript-schema')

const result = formscriptSchema.validateForm(
{
  title: 'Simple demo form!',
  canBeCompletedOffline: true,
  widgets: [
    {
      type: 'header',
      attributes: {
        heading: 'Register!',
        desc: 'Let's get to know each other a bit better...',
        backgroundImage: 'happyPeople.jpg',
        backgroundImageAltText: 'Beautiful people smiling around a laptop'
      }
    },
    {
      id: 'name',
      type: 'text',
      attributes: {
        heading: 'Name',
        placeholder: 'e.g. Lucy Smith',
        mandatory: true,
        minCharacters: 1,
        maxCharacters: 100,
        help: 'Enter your full name here'
      }
    }
  ]
})

if (result.widgetsValid) {
  // All is well!!
} else {
  // Do something with result.errors array.
}

Testing

$ npm test

License

GPLv3

Readme

Keywords

none

Package Sidebar

Install

npm i formscript-schema

Weekly Downloads

5

Version

0.0.5

License

GPLv3

Unpacked Size

132 kB

Total Files

25

Last publish

Collaborators

  • timneedham