std.contract

as:maybe

added in 3.0

(as:maybe v)

creates a maybe

as:optional

added in 3.0

(as:optional k)

creates an optional

closed

added in 3.0

(closed schema)

closes the map

common-spec

added in 3.0

(common-spec sketch & more)

creates a common spec

defcase

macro

added in 3.0

(defcase sym dispatch sketch & more)

adds an additional case to the multispec

defcontract

macro

added in 3.0

(defcontract sym & body)

defines a contract

(type/defspec integer?)

(defcontract -add- :inputs )

(-add- 0.5 0.5) => (throws)

defmultispec

macro

added in 3.0

(defmultispec sym dispatch & pairs)

macro for defining a multispec

defspec

macro

added in 3.0

(defspec sym sketch & more)

macro for defining a spec

from-schema

added in 3.0

(from-schema schema)

sketch from schema

func

macro

added in 3.0

(func args)

macro for constructing a func

lax

added in 3.0

(lax schema)(lax schema ks)

relaxes a map (optional keys and maybe vals)

multi-spec

added in 3.0

(multi-spec dispatch options)

creates a multi spec

norm

added in 3.0

(norm schema)(norm schema ks)

gets rid of optional keys

opened

added in 3.0

(opened schema)

opens the map

remove

added in 3.0

(remove schema ks)

removes a key from map

schema

(schema ?schema)(schema ?schema options)

Creates a Schema object from any of the following:

  • Schema instance (just returns it)
  • IntoSchema instance
  • Schema vector syntax, e.g. :string {:min 1}
  • Qualified Keyword or String, using a registry lookup

schema?

(schema? x)

Checks if x is a Schema instance

spec?

added in 3.0

(spec? x)

checks that object is of type spec

tighten

added in 3.0

(tighten schema)(tighten schema ks)

tightens a map (no optionals or maybes)

to-schema

added in 3.0

(to-schema x)

converts object to schema

valid?

added in 3.0

(valid? spec data)

checks that data is valid