Skip to content

Add function args and return Spec checking via assertions

License

Notifications You must be signed in to change notification settings

Frozenlock/defn-spec

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

defn-spec

A Clojure(Script) wrapper around defn that adds checking to a function's args and/or return value via assertions.

This fork of defn-spec always checks funtion's args and/or return value. It also disallows any provided metadata keys that aren't ret and args to avoid typos.

Clojars Project

Usage

You use defn-spec in the same way you would use defn:

(require '[clojure.spec.alpha :as s])
(require '[defn-spec.core :as ds])

(ds/defn-spec my-inc
  [x]
  (inc x))

This time with specs:

(ds/defn-spec my-inc
  {::ds/args (s/cat :x int?)
   ::ds/ret  nat-int?}
  [x]
  (inc x))

Tests

  • Clojure: lein test
  • Clojurescript: lein doo <js-env> (ex: lein doo phantom)

License

Copyright © 2018 Provisdom

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

Add function args and return Spec checking via assertions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%