Skip to content

Clojure/Script library for function validation of arguments and return value with readable Expound errors

License

Notifications You must be signed in to change notification settings

adamrenklint/preo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

preo

Clojure/Script library for validation of arguments and return value in :pre and :post hooks, with readable Expound errors

Installation

Leiningen/Boot

[com.adamrenklint/preo "0.1.0"]

deps.edn

com.adamrenklint/preo {:mvn/version "0.1.0"}

Usage

(ns example
  (:require [cljs.spec.alpha :as s]
            [preo.core :as p]))

(s/def ::msg string?)
(s/def ::thing (s/keys :req-un [::msg]))

; Use predicate fns or specs, both works
(defn my-fn [msg]
  {:pre [(p/arg! string? msg)]
   :post [(p/ret! ::thing %)]}
  {:msg msg})

Develop

  • Watch and run Clojure tests with socket REPL on port 9000: clj -M:dev-clj
  • Run ClojureScript tests with Shadow CLJS in browser with socket REPL on port 9000: clj -M:dev-cljs

Test

  • Run Clojure tests once: clj -X:test-clj
  • Run ClojureScript tests once: clj -M:test-cljs
  • Run tests on both platforms: clj -T:build run-tests

Release

  • Deploy to Clojars: clj -T:build release

About

Clojure/Script library for function validation of arguments and return value with readable Expound errors

Topics

Resources

License

Stars

Watchers

Forks