"use strict";

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

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

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

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

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