"use strict";

const either = require("@validatem/either");

const isLiteralValue = require("../is-literal-value");

// NOTE: This validator should typically come last in an `either`, since it will catch various types of inputs (sqlExpression, literal values, etc.) that might need to be interpreted differently in specific contexts.

module.exports = function (operations) {
	const isObjectType = require("./is-object-type")(operations);
	const wrapWithOperation = require("./wrap-with-operation")(operations);

	return either([
		[ isObjectType("sqlExpression") ],
		[ isObjectType("literalValue") ],
		[ isObjectType("field") ],
		[ isLiteralValue, wrapWithOperation("value") ]
	]);
};
