UNPKG

somod-schema

Version:

Schema to validate yaml files in somod modules

172 lines (171 loc) 4.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.somodParameter = exports.somodKey = exports.somodJsonStringify = exports.somodJsonParse = exports.somodIf = exports.somodEquals = exports.somodOr = exports.somodAnd = exports.somodAjvCompile = exports.somodFunctions = void 0; exports.somodFunctions = { if: { type: "object", propertyNames: { enum: [ "SOMOD::AjvCompile", "SOMOD::And", "SOMOD::Or", "SOMOD::Equals", "SOMOD::If", "SOMOD::JsonParse", "SOMOD::JsonStringify", "SOMOD::Key", "SOMOD::Parameter" ] } }, then: { oneOf: [ { $ref: "#/definitions/somodAjvCompile" }, { $ref: "#/definitions/somodAnd" }, { $ref: "#/definitions/somodOr" }, { $ref: "#/definitions/somodEquals" }, { $ref: "#/definitions/somodIf" }, { $ref: "#/definitions/somodJsonParse" }, { $ref: "#/definitions/somodJsonStringify" }, { $ref: "#/definitions/somodKey" }, { $ref: "#/definitions/somodParameter" } ] }, else: true }; exports.somodAjvCompile = { type: "object", additionalProperties: false, required: ["SOMOD::AjvCompile"], properties: { "SOMOD::AjvCompile": { anyOf: [ { $ref: "http://json-schema.org/draft-07/schema" }, { $ref: "#/definitions/somodFunctions" } ] } } }; exports.somodAnd = { type: "object", additionalProperties: false, required: ["SOMOD::And"], properties: { "SOMOD::And": { type: "array", items: { anyOf: [{ type: "boolean" }, { $ref: "#/definitions/somodFunctions" }] }, minItems: 1 } } }; exports.somodOr = { type: "object", additionalProperties: false, required: ["SOMOD::Or"], properties: { "SOMOD::Or": { type: "array", items: { anyOf: [{ type: "boolean" }, { $ref: "#/definitions/somodFunctions" }] }, minItems: 1 } } }; exports.somodEquals = { type: "object", additionalProperties: false, required: ["SOMOD::Equals"], properties: { "SOMOD::Equals": { type: "array", items: { anyOf: [true, { $ref: "#/definitions/somodFunctions" }] }, minItems: 2, maxItems: 2 } } }; exports.somodIf = { type: "object", additionalProperties: false, required: ["SOMOD::If"], properties: { "SOMOD::If": { type: "array", additionalItems: { anyOf: [true, { $ref: "#/definitions/somodFunctions" }] }, items: [ { anyOf: [{ type: "boolean" }, { $ref: "#/definitions/somodFunctions" }] } ], minItems: 2, maxItems: 3 } } }; exports.somodJsonParse = { type: "object", additionalProperties: false, required: ["SOMOD::JsonParse"], properties: { "SOMOD::JsonParse": { anyOf: [{ type: "string" }, { $ref: "#/definitions/somodFunctions" }] } } }; exports.somodJsonStringify = { type: "object", additionalProperties: false, required: ["SOMOD::JsonStringify"], properties: { "SOMOD::JsonStringify": { anyOf: [true, { $ref: "#/definitions/somodFunctions" }] } } }; exports.somodKey = { type: "object", additionalProperties: false, required: ["SOMOD::Key"], properties: { "SOMOD::Key": { type: "array", additionalItems: false, items: [ { anyOf: [ { type: "object" }, { type: "array" }, { $ref: "#/definitions/somodFunctions" } ] }, { anyOf: [ { type: "string" }, { type: "number" }, { $ref: "#/definitions/somodFunctions" } ] } ], minItems: 2, maxItems: 2 } } }; exports.somodParameter = { type: "object", additionalProperties: false, required: ["SOMOD::Parameter"], properties: { "SOMOD::Parameter": { type: "string", description: "Must refer the parameter available for this module" } } };