A way better approach for form validation. Feels good now.

This commit is contained in:
2022-07-19 08:24:33 -07:00
parent b84600e4f1
commit cab3a84903
18 changed files with 530 additions and 111 deletions

View File

@@ -2,21 +2,4 @@
(:require [clojure.spec.alpha :as s]
[auto-ap.entities.shared :as shared]))
(s/def ::vendor map?)
(s/def ::vendor-name string?)
(s/def ::client map?)
(s/def ::invoice-number ::shared/required-identifier)
(s/def ::date ::shared/date)
(s/def ::due (s/nilable ::shared/date))
(s/def ::scheduled-payment (s/nilable ::shared/date))
(s/def ::total ::shared/money)
(s/def ::invoice (s/keys :req-un [::client
::invoice-number
::date
::vendor
::total]
:opt-un [::vendor-name
::due
::scheduled-payment
]))

View File

@@ -19,6 +19,9 @@
:ldt? #(instance? org.joda.time.LocalDate %)
:str? (s/and string? #(re-matches date-regex %)))))
(s/def ::required some?)
(s/def ::has-id (s/and map?
#(:id %)))
(s/def ::required-identifier (s/and string?
#(not (str/blank? %))))