You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const { validateOptions } = require("@validatem/core");
|
|
|
|
const required = require("@validatem/required");
|
|
|
|
|
|
|
|
const node = require("../ast-node");
|
|
|
|
|
|
|
|
module.exports = function (operations) {
|
|
|
|
const isCondition = require("../validators/operations/is-condition")(operations);
|
|
|
|
const isPossibleRemoteField = require("../validators/operations/is-possibly-remote-field")(operations);
|
|
|
|
|
|
|
|
return function expression(_options) {
|
|
|
|
let { left, condition } = validateOptions(arguments, {
|
|
|
|
left: [ required, isPossibleRemoteField ], // FIXME: allow sqlExpression and such
|
|
|
|
condition: [ required, isCondition ]
|
|
|
|
});
|
|
|
|
|
|
|
|
// FIXME/MARKER: Rename to 'assert' or something like that?
|
|
|
|
|
|
|
|
return node({
|
|
|
|
type: "expression",
|
|
|
|
left: left,
|
|
|
|
condition: condition
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|