(ns auto-ap.entities.address
  (:require [clojure.spec.alpha :as s]
            [clojure.string :as str]))

(s/def ::street1 (s/nilable string?))
(s/def ::street2 (s/nilable string?))
(s/def ::city (s/nilable string?))
(s/def ::state (s/nilable (s/or
                           :empty (s/and string? #{""})
                           :filled (s/and string?
                                       #(re-matches #"[a-zA-Z]{2}" %)))))
(s/def ::zip  (s/nilable string?))

(s/def ::address (s/keys :opt-un [::email
                                  ::street1
                                  ::street2
                                  ::city
                                  ::state
                                  ::zip]))
