a lot of de-duplicating.

This commit is contained in:
Bryce Covert
2018-04-09 14:25:47 -07:00
parent c82f61bdb4
commit d69b1f2b81
2 changed files with 174 additions and 143 deletions

View File

@@ -1,20 +1,26 @@
(ns auto-ap.entities.vendors
(:require [clojure.spec.alpha :as s]))
(:require [clojure.spec.alpha :as s]
[clojure.string :as str]))
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
(s/def ::id int)
(s/def ::name (s/nilable string?))
(s/def ::identifier (s/nilable string?))
(s/def ::required-identifier (s/and string?
#(not (str/blank? %))))
(s/def ::name ::required-identifier)
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
:is-empty #(= % "")))))
(s/def ::phone (s/nilable string?))
(s/def ::data (s/nilable string?))
(s/def ::invoice-reminder-schedule (s/nilable string?))
(s/def ::primary-contact ::name)
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
(s/def ::primary-contact ::identifier)
(s/def ::primary-email ::email)
(s/def ::primary-phone ::phone)
(s/def ::secondary-contact ::name)
(s/def ::secondary-contact ::identifier)
(s/def ::secondary-email ::email)
(s/def ::secondary-phone ::phone)