(ns auto-ap.schema
  (:require [malli.core :as m]))

(def reference (m/schema [:map [:id :string]]))
(def date (m/schema [:fn 
                     (fn [d]
                       (if-not (or (instance? goog.date.DateTime d)
                                   (instance? goog.date.Date d))
                         (throw (ex-info "Invalid Date" {:type ::m/invalid-type}))
                         true))]))

(def money (m/schema [float? {:error/message "Invalid money"}]))
(def not-empty-string (m/schema [:re {:error/message "Required"} #"\S+"]))
(def code-string (m/schema [:re #"[A-Z0-9\-]+"]))

(def integer-code (m/schema [:int {:min 10000 :max 99999}]))

(def approval-status (m/schema [:enum :unapproved :requires-feedback :approved :excluded]))
