3.10.6 • Published 4 years ago

smartmate-schemas v3.10.6

Weekly downloads
94
License
UNLICENSED
Repository
bitbucket
Last release
4 years ago

Smartmate Schemas

Schemas for validating a smartmate workspace and its components.

Installation

yarn add smartmate-schemas
# or npm i smartmate-schemas

Usage

This module will return an instance of Ajv, loaded will all the smartmate schemas.

const schemas = require('smartmate-schemas');

const isValid = schemas.validate('workspaces/smartmate-file.schema', myWorkspaceJson);
if (!isValid) console.log(schemas.errors);

# [] or [{"app":{"yourApp":{"errors":[{"keyword":"enum","dataPath":".spec.menu[0].type","schemaPath":"#/definitions/menuItem/properties/type/enum","params":{"allowedValues":["table"]},"message":"should be equal to one of the allowed values"}]}}}]

Development

Local check

const schemas = require('./src');

const isFormValid = schemas.validate('forms/form.schema', {
  'name': 'MyForm',
  'rows': [
    'field1',
    {
      'isActive': {
        'label': 'IS ACTIVE',
      },
    },
    '_parent(table.field)',
    '_parent(table.field).name',
  ],
});

if (!isFormValid) {
  console.error(schemas.errors);
}

Adding a new field type

Under schemas/field/types directory create a new directory with the name of your new type and add the following files inside:

  • <your-new-type>.valid.yaml - A valid example of the new type.
  • <your-new-type>.schema.json - Actual JSON schema for validation.
  • <your-new-type>.methods-to-invalidate.js - Methods for unit testing the schema.

Finally add a new entry for your new type in schemaFiles.js

Adding a new row type for forms

Under schemas/form/rows/types directory create the following files:

  • <your-new-type>.valid.yaml - A valid example of the new type.
  • <your-new-type>.schema.json - Actual JSON schema for validation.
  • <your-new-type>.methods-to-invalidate.js - Methods for unit testing the schema (tests that will fail).

Add your new type in src/schemaFile.js file:

...
'forms/rows/types/<your-new-type>.schema.json',
...

Finally, add a new entry under anyOf in schemas/forms/rows/row.schema.json:

  ...
  "anyOf": {
    ...
    { "$ref": "https://schemas.apps.smartmate.io/forms/rows/types/<your-new-type>.schema.json"}
  }
3.10.5

4 years ago

3.10.6

4 years ago

3.10.3

5 years ago

3.10.2

5 years ago

3.10.1

5 years ago

3.9.2

5 years ago

3.9.1

5 years ago

3.8.3

5 years ago

3.8.2

5 years ago

3.8.1

5 years ago

3.7.4

5 years ago

3.7.3

5 years ago

3.7.2

5 years ago

3.6.14

5 years ago

3.7.1

5 years ago

3.6.13

5 years ago

3.6.12

5 years ago

3.6.11

5 years ago

3.6.10

5 years ago

3.6.9

5 years ago

3.6.8

5 years ago

3.6.7

5 years ago

3.6.6

5 years ago

3.6.5

5 years ago

3.6.4

5 years ago

3.6.3

5 years ago

3.6.2

5 years ago

3.6.1

5 years ago

3.5.1

5 years ago

3.4.2

5 years ago

3.4.1

5 years ago

3.3.1

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.1.6

5 years ago

3.1.5

5 years ago

3.1.4

5 years ago

3.1.3

5 years ago

3.1.2

5 years ago

3.1.1

5 years ago

3.0.4

5 years ago

3.0.3

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.3

5 years ago

2.0.4

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago