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.
37 lines
897 B
JavaScript
37 lines
897 B
JavaScript
"use strict";
|
|
|
|
const { validateArguments } = require("@validatem/core");
|
|
const required = require("@validatem/required");
|
|
|
|
const unreachable = require("../unreachable");
|
|
const node = require("../ast-node");
|
|
|
|
module.exports = function (operations) {
|
|
const isPredicateList = require("../validators/operations/is-predicate-list")(operations);
|
|
|
|
return function anyOf(_items) {
|
|
let [ items ] = validateArguments(arguments, {
|
|
items: [ required, isPredicateList ]
|
|
});
|
|
|
|
if (items.type === "values") {
|
|
return node({
|
|
type: "anyOfValues",
|
|
items: items.value
|
|
});
|
|
} else if (items.type === "conditions") {
|
|
return node({
|
|
type: "anyOfConditions",
|
|
items: items.value
|
|
});
|
|
} else if (items.type === "expressions") {
|
|
return node({
|
|
type: "anyOfExpressions",
|
|
items: items.value
|
|
});
|
|
} else {
|
|
unreachable(`Invalid tagged type '${items.type}'`);
|
|
}
|
|
};
|
|
};
|