UNPKG

ajv-json-logic

Version:
35 lines (32 loc) 1.04 kB
import conditionalSchemaMetaSchema from '../schemas/conditional-schema.json.js'; function getDef() { return { keyword: 'conditionalSchema', macro: function (schema) { if (!schema) { return {}; } const allOf = []; if (!Array.isArray(schema)) schema = [schema]; if (schema && Array.isArray(schema)) { schema.forEach(({ rule, schema: childSchema }) => { allOf.push({ if: { jsonLogic: rule }, then: childSchema, }); }); return { allOf }; } return {}; }, metaSchema: conditionalSchemaMetaSchema, }; } // For CommonJS compatibility if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { module.exports = getDef; module.exports.default = getDef; } export { getDef as default }; //# sourceMappingURL=conditionalSchema.js.map