viewscript-schema

0.0.6 • Public • Published

viewscript-schema

Known Vulnerabilities

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

Install

$ npm install viewscript-schema --save

Usage

const viewscriptSchema = require('viewscript-schema')

const result = viewscriptSchema.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

Dependencies (3)

Dev Dependencies (4)

Package Sidebar

Install

npm i viewscript-schema

Weekly Downloads

0

Version

0.0.6

License

GPLv3

Unpacked Size

104 kB

Total Files

23

Last publish

Collaborators

  • timneedham