ajv-json-logic
Version:
JSON Logic integration for Ajv validator
27 lines (24 loc) • 695 B
JavaScript
import jsonLogic from 'json-logic-js';
import jsonLogicSchema from '../schemas/json-logic.json.js';
function getDef() {
return {
keyword: 'jsonLogic',
validate: function (logicRule, data) {
try {
return !!jsonLogic.apply(logicRule, data);
}
catch (e) {
return false;
}
},
errors: false,
metaSchema: jsonLogicSchema,
};
}
// For CommonJS compatibility
if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = getDef;
module.exports.default = getDef;
}
export { getDef as default };
//# sourceMappingURL=jsonLogic.js.map