Data Specs
Data Specs
(maybe v)Makes a value nillable:
{:name string?
:age (ds/maybe int?)}
Makes a value nillable:
```clojure
{:name string?
:age (ds/maybe int?)}
```(maybe? x)Test if the value is wrapped with maybe
Test if the value is wrapped with [[maybe]]
(opt k)Makes a key optional:
{:name string?
(ds/opt :age) int?}
Makes a key optional:
```clojure
{:name string?
(ds/opt :age) int?}
```(opt? x)Test if the key is wrapped with opt
Test if the key is wrapped with [[opt]]
(req k)Makes a key required:
{:name string?
(ds/req :age) int?}
Makes a key required:
```clojure
{:name string?
(ds/req :age) int?}
```(req? x)Test if the key is wrapped with req
Test if the key is wrapped with [[req]]
(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:
| Key | Description |
|---|---|
:spec | The wrapped data-spec. |
:name | Qualified root spec name - used to generate unique names for sub-specs. |
:keys-spec | Function to wrap not-wrapped keys, e.g. opt to make keys optional by default. |
:keys-default | Function to generate the keys-specs, default [[keys-specs]]. |
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 wrap not-wrapped keys, e.g. [[opt]] to make keys optional by default.
| `:keys-default` | Function to generate the keys-specs, default [[keys-specs]].cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |