You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
"use strict" ;
const either = require ( "@validatem/either" ) ;
const wrapError = require ( "@validatem/wrap-error" ) ;
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.
// FIXME: Rename valueExpression -> value?
module . exports = function ( operations ) {
const isObjectType = require ( "./is-object-type" ) ( operations ) ;
const isColumnObject = require ( "./is-column-object" ) ( operations ) ;
const isAggregrateFunction = require ( "./is-aggregrate-function" ) ( operations ) ;
const wrapWithOperation = require ( "./wrap-with-operation" ) ( operations ) ;
return wrapError ( "Must be a type of value" , either ( [
[ isObjectType ( "sqlExpression" ) ] ,
[ isObjectType ( "literalValue" ) ] ,
[ isObjectType ( "placeholder" ) ] , // TODO: Verify that this also works for the `alias` method
[ isAggregrateFunction ] ,
[ isColumnObject ] ,
[ isLiteralValue , wrapWithOperation ( "value" ) ]
] ) ) ;
} ;