Liking cljdoc? Tell your friends :D

spec-tools.data-spec

Data Specs

Data Specs

maybe

(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

source

maybe?

(maybe? x)

Test if the value is wrapped with maybe

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

opt

(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?

(opt? x)

Test if the key is wrapped with opt

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

OptionalKey

source

or

(or v)
source

or?

(or? x)
source

req

(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?

(req? x)

Test if the key is wrapped with req

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

RequiredKey

source

spec

(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]].
sourceraw docstring

unwrap-key

(unwrap-key x)

Unwrap the opt or req key.

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

wrapped-key?

(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