Sha256: dc885ce180032291ec73f208da1a4a7c0098036235b3d9f2cbf9bf95d18a806e

Contents?: true

Size: 1002 Bytes

Versions: 49

Compression:

Stored size: 1002 Bytes

Contents

'use strict';

module.exports = function defFunc(ajv) {
  if (ajv.RULES.keywords.switch)
    return console.warn('Keyword switch is already defined');

  var metaSchemaUri = ajv._opts.v5
                      ? 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-v5.json#'
                      : 'http://json-schema.org/draft-04/schema#';

  defFunc.definition = {
    inline: require('./dotjs/switch'),
    statements: true,
    errors: 'full',
    metaSchema: {
      type: 'array',
      items: {
        required: [ 'then' ],
        properties: {
          'if': { $ref: metaSchemaUri },
          'then': {
            anyOf: [
              { type: 'boolean' },
              { $ref: metaSchemaUri }
            ]
          },
          'continue': { type: 'boolean' }
        },
        additionalProperties: false,
        dependencies: {
          'continue': [ 'if' ]
        }
      }
    }
  };

  ajv.addKeyword('switch', defFunc.definition);
  return ajv;
};

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
ilog-0.4.1 node_modules/ajv-keywords/keywords/switch.js
ilog-0.4.0 node_modules/ajv-keywords/keywords/switch.js
ilog-0.3.3 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-18.0.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.21.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.20.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.19.1 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.19.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.18.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.17.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.16.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.15.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.14.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.13.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.12.2 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.12.1 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.12.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.11.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.10.0 node_modules/ajv-keywords/keywords/switch.js
govuk_publishing_components-17.9.0 node_modules/ajv-keywords/keywords/switch.js