"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 isSelectionField = require("../validators/operations/is-selection-field")(operations); // FIXME: This needs a more descriptive name. Selectable field?

	return function addFields(_fields) {
		let [ fields ] = validateArguments(arguments, {
			fields: [ required, arrayOf([ required, isSelectionField ]) ]
		});

		return node({ type: "addFields", fields: fields });
	};
};
