A way better approach for form validation. Feels good now.
This commit is contained in:
@@ -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
|
||||
]))
|
||||
|
||||
@@ -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? %))))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user