(ns auto-ap.entities.shared
  (:require [clojure.spec.alpha :as s]
            [clojure.string :as str]))

(def date-regex #"[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")
(def money-regex #"\-?[0-9]+(\.[0-9]{1,2})?$")

(s/def ::identifier (s/nilable string?))
(s/def ::date (s/and string? #(re-matches date-regex %)))
(s/def ::required-identifier (s/and string?
                                    #(not (str/blank? %))))

(s/def ::money (s/and string?
                      #(re-matches money-regex %)))
