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.
32 lines
785 B
JavaScript
32 lines
785 B
JavaScript
4 years ago
|
"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 allOf(_items) {
|
||
|
let [ items ] = validateArguments(arguments, {
|
||
|
items: [ required, isPredicateList ]
|
||
|
});
|
||
|
|
||
|
if (items.type === "conditions") {
|
||
|
return node({
|
||
|
type: "allOfConditions",
|
||
|
items: items.value
|
||
|
});
|
||
|
} else if (items.type === "expressions") {
|
||
|
return node({
|
||
|
type: "allOfExpressions",
|
||
|
items: items.value
|
||
|
});
|
||
|
} else {
|
||
|
unreachable(`Invalid tagged type '${items.type}'`);
|
||
|
}
|
||
|
};
|
||
|
};
|