"use strict";

const { validateArguments } = require("@validatem/core");
const required = require("@validatem/required");

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

module.exports = function (operations) {
	return function indexWhere(_expression) {
		const isExpression = require("../../validators/operations/is-expression")(operations);

		let [ expression ] = validateArguments(arguments, {
			expression: [ required, isExpression ]
		});

		return node({
			type: "index",
			expression: expression
		});
	};
};
