more specs.
This commit is contained in:
22
src/cljc/auto_ap/entities/companies.cljc
Normal file
22
src/cljc/auto_ap/entities/companies.cljc
Normal file
@@ -0,0 +1,22 @@
|
||||
(ns auto-ap.entities.companies
|
||||
(: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 ::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 ::company (s/keys :req [::name]
|
||||
:opt [::email
|
||||
::id]))
|
||||
|
||||
|
||||
(def company-spec (apply hash-map (drop 1 (s/form ::company))))
|
||||
(def all-keys (concat (:req company-spec) (:opt company-spec)))
|
||||
Reference in New Issue
Block a user