"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");
const arrayOf = require("@validatem/array-of");

const node = require("../ast-node");

module.exports = function (operations) {
	const isSelectionColumn = require("../validators/operations/is-selection-column")(operations);

	return function onlyColumns(_columns) {
		let [ columns ] = validateArguments(arguments, {
			columns: [ required, arrayOf([ required, isSelectionColumn ]) ]
		});

		return node({ type: "onlyColumns", columns: columns });
	};
};
