Skip to content

Generative testing

Clojure specifications for next.jdbc

Specifications define the shape of data used for the application. The specifications are defined across two namespaces, general data specifications in practicalli.specifications and banking specific specs in the practicalli.specifications-banking namespace.

Basic customer details

(spec/def ::first-name string?)
(spec/def ::last-name string?)
(spec/def ::email-address string?)

;; residential address values
(spec/def ::house-name-number (spec/or :string string?
                                       :number int?))
(spec/def ::street-name string?)
(spec/def ::post-code string?)
(spec/def ::county string?)

countries of the world as a set, containing a string for each country defined in the practicalli.specifications namespace

(spec/def ::country :practicalli.specifications/countries-of-the-world)
(spec/def ::residential-address (spec/keys :req [::house-name-number ::street-name ::post-code]
                                           :opt [::county ::country]))
(spec/def ::social-security-id-uk string?)
(spec/def ::social-security-id-usa string?)

(spec/def ::social-security-id (spec/or ::social-security-id-uk
;; composite customer details specification
(spec/def ::customer-details
    :req [::first-name ::last-name ::email-address ::residential-address ::social-security-id]))

Banking data specificationsλ︎

The specifications-banking sets the overall context for the specifications defined in the namespace.

account-id is a unique identification across all accounts in the bank. The type of value used is a universally unique identifier (UUID) is a 128-bit number used to identify information in computer systems. Clojure uses a #uuid tag literal

(spec/def ::account-id uuid?)

;; Account holder - composite specification
(spec/def ::account-holder
    :req [::account-id