Liking cljdoc? Tell your friends :D

fulcro-spec.check


all*clj/s

(all* c & cs)

Takes one or more checkers, and returns a new checker. That checker takes an actual argument, and calls every checker with it as the first and only argument. Returns nil or a sequence of maps matching check-failure?.

Takes one or more `checker`s, and returns a new `checker`.
That checker takes an `actual` argument, and calls every checker with it as the first and only argument.
Returns nil or a sequence of maps matching `check-failure?`.
sourceraw docstring

and*clj/s

(and* c & cs)

Takes one or more checkers, and returns a new checker. That checker takes an actual argument, and calls each checker in succession, short circuiting if any returned a check-failure?. Returns nil or a sequence of maps matching check-failure?.

Takes one or more `checker`s, and returns a new `checker`.
That checker takes an `actual` argument, and calls each checker in succession, short circuiting if any returned a `check-failure?`.
Returns nil or a sequence of maps matching `check-failure?`.
sourceraw docstring

assert-are-checkers!clj/s

(assert-are-checkers! tag checkers)

Helper to ensure that checker "combinators" are passed checkers. The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of. eg: (assert-are-checkers!and* checkers)`

Helper to ensure that checker "combinators" are passed checkers.
The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of.
eg: `(assert-are-checkers! `and* checkers)`
sourceraw docstring

assert-is!clj/smacro

(assert-is! tag pred value)

Helper macro to assert that values satisfy a predicate. The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of. eg: (assert-is!is?* ifn? predicate)`

Helper macro to assert that values satisfy a predicate.
The tag can be anything, but by convention should be the namespaced qualified symbol of the checker this function is inside of.
eg: `(assert-is! `is?* ifn? predicate)`
sourceraw docstring

behavior*clj/s

(behavior* string c & cs)

NOTE: experimental, may be considered poor form and deprecated at a later date. Equivalent to fulcro-spec.core/behavior, so you can describe the expected behavior being checked. eg: 2.0 =check=> (_/behavior* "is a double" (_/is?* double?))

NOTE: experimental, may be considered poor form and deprecated at a later date.
Equivalent to `fulcro-spec.core/behavior`, so you can describe the expected behavior being checked.
eg: `2.0 =check=> (_/behavior* "is a double" (_/is?* double?))`
sourceraw docstring

checkerclj/smacro

(checker arglist & args)

Creates a function that takes only one argument (usually named actual). For use in =check=> assertions. NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of this checker macro.

Creates a function that takes only one argument (usually named `actual`).
For use in =check=> assertions.
NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of this `checker` macro.
sourceraw docstring

checker?clj/s

(checker? x)

Checks if passed in argument was a function created by the checker macro. NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of the checker macro.

Checks if passed in argument was a function created by the `checker` macro.
NOTE: the fact that a checker is just a fn with metadata is an internal detail, do not rely on that fact, and prefer usage of the `checker` macro.
sourceraw docstring

embeds?*clj/s

(embeds?* expected)

Takes a map and returns a checker that checks if the values at the keys match (using =) . The map values can be checkers, but will throw an error if passed a raw function. The map can be arbitrarily nested with further maps, eg:

(embeds?* {:a 1, :b {:c (is?* even?)}}) =check=> {:a 1, :b {:c 2}}

Can also check that a key value pair was not found by checking for equality with ::not-found, eg:

(embeds?* {:a ::not-found}) =check=> {}
Takes a map and returns a checker that checks if the values at the keys match (using `=`) .
The map values can be `checker`s, but will throw an error if passed a raw function.
The map can be arbitrarily nested with further maps, eg:
```
(embeds?* {:a 1, :b {:c (is?* even?)}}) =check=> {:a 1, :b {:c 2}}
```
Can also check that a key value pair was not found by checking for equality with ::not-found, eg:
```
(embeds?* {:a ::not-found}) =check=> {}
```
sourceraw docstring

equals?*clj/s

(equals?* expected)

Takes any value and returns a checker that checks for equality.

Takes any value and returns a checker that checks for equality.
sourceraw docstring

every?*clj/s

(every?* c & cs)

Takes one or more checkers, and returns a checker that runs all checker arguments on each element of the checker argument sequence. WARNING: checks every item in the actual sequence, unlike every?. WARNING: will pass if given an empty sequence, like every?. If not desireable, compose (is?* seq) or (of-length? ...) before this checker. NOTE: will short circuit execution of expected checkers using the same semantics as and*.

Takes one or more checkers, and returns a checker that runs all checker arguments on each element of the checker argument sequence.
WARNING: checks every item in the `actual` sequence, unlike `every?`.
WARNING: will pass if given an empty sequence, like `every?`.
If not desireable, compose `(is?* seq)` or `(of-length? ...)` before this checker.
NOTE: will short circuit execution of expected checkers using the same semantics as `and*`.
sourceraw docstring

ex-data*clj/s

(ex-data* c & cs)

Checks that the actual value is an ExceptionInfo. If successful, passes the ex-data to all* passed in checkers.

Checks that the `actual` value is an `ExceptionInfo`.
If successful, passes the `ex-data` to `all*` passed in checkers.
sourceraw docstring

exception*clj/s

(exception* c & cs)

Checks that the actual value is an Exception (or in cljs a js/Error). If successful, passes the Exception to all* passed in checkers.

Checks that the `actual` value is an `Exception` (or in cljs a `js/Error`).
If successful, passes the `Exception` to `all*` passed in checkers.
sourceraw docstring

exists?*clj/s

(exists?* & [msg])

Takes an optional failure message and returns a checker that checks for non-nil values.

Takes an optional failure message and returns a checker that checks for non-nil values.
sourceraw docstring

fmap*clj/s

(fmap* f c)

Creates a new checker that is the result of applying the function to the checker arguments before passing it to the wrapped checker. Eg: [:b :c :a] =check=> (fmap* sort (equals?* [:a :b :c]))

Creates a new checker that is the result of applying the function to the checker arguments before passing it to the wrapped checker.
Eg: `[:b :c :a] =check=> (fmap* sort (equals?* [:a :b :c]))`
sourceraw docstring

in*clj/s

(in* path c & cs)

Takes a path and one or more checkers, and returns a checker that focuses the checker argument on the result of running (get-in actual path). If the call to get-in failed it returns a check-failure?.

Takes a path and one or more checkers, and returns a checker that focuses the checker argument on the result of running `(get-in actual path)`.
If the call to `get-in` failed it returns a `check-failure?`.
sourceraw docstring

is?*clj/s

(is?* predicate)

Takes any truthy predicate function and returns a checker that checks with said predicate.

Takes any truthy predicate function and returns a checker that checks with said predicate.
sourceraw docstring

of-length?*clj/s

(of-length?* expected-length)
(of-length?* min-len max-len)

Checks that given seqable? collection has the expected length. Has two arities:

  • The first checks that the actual length is equal to the expected-length.
  • The second, takes two numbers and verifies that the actual length is between (inclusively) the two numbers.
Checks that given `seqable?` collection has the expected length.
Has two arities:
- The first checks that the actual length is equal to the `expected-length`.
- The second, takes two numbers and verifies that the actual length is between (inclusively) the two numbers.
sourceraw docstring

re-find?*clj/s

(re-find?* regex)

Takes a regex (or string) and returns a checker that checks using re-find. NOTE: Will first check that the incoming data (actual) is a string?

Takes a regex (or string) and returns a checker that checks using `re-find`.
NOTE: Will first check that the incoming data (`actual`) is a `string?`
sourceraw docstring

seq-matches-exactly?*clj/s

(seq-matches-exactly?* expected)

Takes a sequential? collection, and returns a checker that checks its argument in a sequential manner. NOTE: "exactly" means that the actual collection is checked to have the exact same length as the expected collection. Eg: (seq-matches-exactly?* [1 2]) =check=> [1 2] Can also take checkers as values, eg: (seq-matches-exactly?* [(is?* pos?)]) =check=> [42]

Takes a `sequential?` collection, and returns a checker that checks its argument in a sequential manner.
NOTE: "exactly" means that the `actual` collection is checked to have the **exact** same length as the `expected` collection.
Eg:
`(seq-matches-exactly?* [1 2]) =check=> [1 2]`
Can also take checkers as values, eg:
`(seq-matches-exactly?* [(is?* pos?)]) =check=> [42]`
sourceraw docstring

seq-matches?*clj/s

(seq-matches?* expected)

Takes a sequential? collection, and returns a checker that checks its argument in a sequential manner, ie: (seq-matches?* [1 2]) =check=> [1 2]

NOTE: does NOT check if the actual collection contains more or fewer items than expected! If not desireable, use seq-matches-exactly?* instead.

Can also take checkers as values, eg: (seq-matches?* [(is?* pos?)]) =check=> [42]

Takes a `sequential?` collection, and returns a checker that checks its argument in a sequential manner, ie:
`(seq-matches?* [1 2]) =check=> [1 2]`

NOTE: does **NOT** check if the `actual` collection contains more or fewer items than expected! If not desireable, use `seq-matches-exactly?*` instead.

Can also take checkers as values, eg:
`(seq-matches?* [(is?* pos?)]) =check=> [42]`
sourceraw docstring

subset?*clj/s

(subset?* expected)

Takes an expected set, and will check that actual contains only a subset of what is expected. Eg:

; PASSES
#{:a} =check=> (subset?* #{:a :b})

; FAILS
#{:a :b :c} =check=> (subset?* #{:a :b})
Takes an `expected` set, and will check that `actual` contains only a subset of what is expected.
Eg:
```
; PASSES
#{:a} =check=> (subset?* #{:a :b})

; FAILS
#{:a :b :c} =check=> (subset?* #{:a :b})
```
sourceraw docstring

throwable*clj/s

(throwable* c & cs)

Checks that the actual value is a Throwable (or in cljs a js/Error). If successful, passes the Throwable to all* passed in checkers.

Checks that the `actual` value is a `Throwable` (or in cljs a `js/Error`).
If successful, passes the `Throwable` to `all*` passed in checkers.
sourceraw docstring

valid?*clj/s

(valid?* spec)

Takes any valid clojure.spec.alpha/spec and returns a checker. The checker checks with s/valid? and calls s/explain-str for the :message.

Takes any valid clojure.spec.alpha/spec and returns a checker.
The checker checks with `s/valid?` and calls `s/explain-str` for the `:message`.
sourceraw docstring

with-message*clj/s

(with-message* message c & cs)

Appends the message to all failures that the checker may return. eg: 2.0 =check=> (_/with-message* "some info" (_/is?* double?))

Appends the message to all failures that the checker may return.
eg: `2.0 =check=> (_/with-message* "some info" (_/is?* double?))`
sourceraw docstring

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

× close