a good experience for dates.

This commit is contained in:
2022-07-17 06:40:46 -07:00
parent 2830004092
commit eba3a5dce3
8 changed files with 240 additions and 619 deletions

View File

@@ -1,14 +1,24 @@
(ns auto-ap.entities.shared
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]))
[clojure.string :as str]
))
(def date-regex #"[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}")
(def date-regex #"[2]{1}[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}")
(def money-regex #"\-?[0-9]+(\.[0-9]{2})?$")
(def numeric-regex #"^[0-9]+$")
(def only-upper-case #"^[A-Z]+$")
(s/def ::identifier (s/nilable string?))
(s/def ::date (s/and string? #(re-matches date-regex %)))
(s/def ::date
#?(:cljs
(s/or :dt? #(instance? goog.date.DateTime %)
:d? #(instance? goog.date.Date %)
:str? (s/and string? #(re-matches date-regex %)))
:clj (s/or :dt? #(instance? org.joda.time.DateTime %)
:ldt? #(instance? org.joda.time.LocalDateTime %)
:ldt? #(instance? org.joda.time.LocalDate %)
:str? (s/and string? #(re-matches date-regex %)))))
(s/def ::required-identifier (s/and string?
#(not (str/blank? %))))