Liking cljdoc? Tell your friends :D

spec-tools.data-spec

Data Specs

Data Specs
raw docstring

maybeclj/s

(maybe v)

Makes a value nillable:

{:name string?
 :age (ds/maybe int?)}
Makes a value nillable:

```clojure
{:name string?
 :age (ds/maybe int?)}
```
sourceraw docstring

maybe?clj/s

(maybe? x)

Test if the value is wrapped with maybe

Test if the value is wrapped with [[maybe]]
sourceraw docstring

optclj/s

(opt k)

Makes a key optional:

{:name string?
 (ds/opt :age) int?}
Makes a key optional:

```clojure
{:name string?
 (ds/opt :age) int?}
```
sourceraw docstring

opt?clj/s

(opt? x)

Test if the key is wrapped with opt

Test if the key is wrapped with [[opt]]
sourceraw docstring

orclj/s

(or v)
source

or?clj/s

(or? x)
source

reqclj/s

(req k)

Makes a key required:

{:name string?
 (ds/req :age) int?}
Makes a key required:

```clojure
{:name string?
 (ds/req :age) int?}
```
sourceraw docstring

req?clj/s

(req? x)

Test if the key is wrapped with req

Test if the key is wrapped with [[req]]
sourceraw docstring

specclj/s

(spec {data :spec name :name nested? :spec-tools.data-spec/nested? :as opts})
(spec name data)

Creates a clojure.spec.alpha/Spec out of a data-spec. Supports 2 arities:

;; arity1
(ds/spec
  {:spec {:i int?}
   :name ::map})

;; arity2 (legacy)
(ds/spec ::map {:i int?})

The following options are valid for the 1 arity case:

KeyDescription
:specThe wrapped data-spec.
:nameQualified root spec name - used to generate unique names for sub-specs.
:keys-specFunction to generate the keys-specs, default [[keys-specs]].
:keys-defaultFunction to wrap not-wrapped keys, e.g. opt to make keys optional by default.
Creates a `clojure.spec.alpha/Spec` out of a data-spec. Supports 2 arities:

```clojure
;; arity1
(ds/spec
  {:spec {:i int?}
   :name ::map})

;; arity2 (legacy)
(ds/spec ::map {:i int?})
```

The following options are valid for the 1 arity case:

| Key              | Description
| -----------------|----------------
| `:spec`          | The wrapped data-spec.
| `:name`          | Qualified root spec name - used to generate unique names for sub-specs.
| `:keys-spec`     | Function to generate the keys-specs, default [[keys-specs]].
| `:keys-default`  | Function to wrap not-wrapped keys, e.g. [[opt]] to make keys optional by default.
sourceraw docstring

unwrap-keyclj/s

(unwrap-key x)

Unwrap the opt or req key.

Unwrap the [[opt]] or [[req]] key.
sourceraw docstring

wrapped-key?clj/s

(wrapped-key? x)

Test if the key is wrapped with opt or req

Test if the key is wrapped with [[opt]] or [[req]]
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close