Predicate functions for checking whether something is a valid instance of a given MBQL clause.

(ns metabase.legacy-mbql.predicates
  (:require
   [metabase.legacy-mbql.schema :as mbql.s]
   [metabase.lib.schema.temporal-bucketing :as lib.schema.temporal-bucketing]
   [metabase.util.malli.registry :as mr]))

Is unit a valid datetime bucketing unit?

(def ^{:arglists '([unit])} DateTimeUnit?
  (mr/validator ::lib.schema.temporal-bucketing/unit))

Is this a valid Field clause?

(def ^{:arglists '([field-clause])} Field?
  (mr/validator mbql.s/Field))

Is this a valid :filter clause?

(def ^{:arglists '([filter-clause])} Filter?
  (mr/validator mbql.s/Filter))

Is this a valid DatetimeExpression clause?

(def ^{:arglists '([filter-clause])} DatetimeExpression?
  (mr/validator mbql.s/DatetimeExpression))

Is this a something that is valid as a top-level expression definition?

(def ^{:arglists '([field-clause])} FieldOrExpressionDef?
  (mr/validator ::mbql.s/FieldOrExpressionDef))