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?)}
```
raw docstring

Maybecljs


maybe?clj/s

(maybe? x)

Test if the value is wrapped with maybe

Test if the value is wrapped with [[maybe]]
raw 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?}
```
raw docstring

opt?clj/s

(opt? x)

Test if the key is wrapped with opt

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

OptionalKeycljs


orclj/s

(or v)

Orcljs


or?clj/s

(or? x)

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?}
```
raw docstring

req?clj/s

(req? x)

Test if the key is wrapped with req

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

RequiredKeycljs


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 wrap not-wrapped keys, e.g. opt to make keys optional by default.
:keys-defaultFunction 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]].
raw docstring

unwrap-keyclj/s

(unwrap-key x)

Unwrap the opt or req key.

Unwrap the [[opt]] or [[req]] key.
raw 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]]
raw docstring

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

× close