Liking cljdoc? Tell your friends :D

com.ben-allred.formation.core


hydrateclj/s

(hydrate hydrator config)

Creates a validator that hydrates the stored value for validation.

(let [validator (hydrate widget-id->widget widget-validator)] (validator widget-id))

Creates a validator that hydrates the stored value for validation.

(let [validator (hydrate widget-id->widget widget-validator)]
  (validator widget-id))
sourceraw docstring

identityclj/s

(identity f msg)

Creates a validator that produces a msg when the value does not equal the result of passing the value through the identity function. Does not validate nil.

(identity sort "must be sorted")

Creates a validator that produces a msg when the value does not equal the result of
passing the value through the identity function. Does not validate nil.

(identity sort "must be sorted")
sourceraw docstring

ifn->fnclj/sdeprecated

(ifn->fn ifn)

Deprecated. Use ::ifn metadata instead.

Utility wrapper for maps when you want to use them as a transforming function because make-transformer treats maps as nested transformations.

Deprecated. Use ::ifn metadata instead.

Utility wrapper for maps when you want to use them as a transforming function
because make-transformer treats maps as nested transformations.
sourceraw docstring

make-transformerclj/sdeprecated

(make-transformer config)

Deprecated. Use transformer instead.

Deprecated. Use `transformer` instead.
sourceraw docstring

make-validatorclj/sdeprecated

(make-validator config)

Deprecated. Use validator instead.

Deprecated. Use `validator` instead.
sourceraw docstring

matchesclj/s

(matches re msg)

Creates a validator that produces a msg when the value does not match a given regular expression or the value is not a string. Does not validate nil.

(matches #"[0-9]{4,}" "at least 4 digits")

Creates a validator that produces a msg when the value does not match a given regular
expression or the value is not a string. Does not validate nil.

(matches #"[0-9]{4,}" "at least 4 digits")
sourceraw docstring

max-lengthclj/s

(max-length n msg)

Creates a validator that produces a msg when the length of the value is not at least what is specified. Does not validate nil.

(max-length 10 "must be at most 10")

Creates a validator that produces a msg when the length of the value is not at least
what is specified. Does not validate nil.

(max-length 10 "must be at most 10")
sourceraw docstring

min-lengthclj/s

(min-length n msg)

Creates a validator that produces a msg when the length of the value is not at least what is specified. Does not validate nil.

(min-length 10 "must be at least 10")

Creates a validator that produces a msg when the length of the value is not at least
what is specified. Does not validate nil.

(min-length 10 "must be at least 10")
sourceraw docstring

predclj/s

(pred p msg)

Creates a validator that produces a msg when a value does not satisfy the predicate. Does not validate nil.

(pred string? "needs to be a string")

Creates a validator that produces a msg when a value does not satisfy the predicate.
Does not validate nil.

(pred string? "needs to be a string")
sourceraw docstring

requiredclj/s

(required msg)

Creates a validator that produces a msg when a value is nil.

(required "this is required")

Creates a validator that produces a msg when a value is nil.

(required "this is required")
sourceraw docstring

transformerclj/s

(transformer config)

Creates a transforming function that transforms a value through a data config.

(transformer {:person {:email string/lower-case :attributes ^::map-of {keyword str}}})

Creates a transforming function that transforms a value through a data config.

(transformer {:person {:email string/lower-case :attributes ^::map-of {keyword str}}})
sourceraw docstring

validatorclj/s

(validator config)

Create a validating function from a configuration.

(validator {:a (pred number? "must be a number") :b (required "required")}

Create a validating function from a configuration.

(validator {:a (pred number? "must be a number") :b (required "required")}
sourceraw docstring

validator-collclj/sdeprecated

(validator-coll config)

Deprecated. Use ::coll-of metadata instead.

(validator ^::coll-of [[(required "required") (pred string? "string")]])

Deprecated. Use ::coll-of metadata instead.

(validator ^::coll-of [[(required "required") (pred string? "string")]])
sourceraw docstring

validator-mapclj/sdeprecated

(validator-map key-config val-config)

Deprecated. Use ::map-of metadata instead.

(validator ^::map-of {[(required "required") (pred keyword? "keyword")] val-validator})

Deprecated. Use ::map-of metadata instead.

(validator ^::map-of {[(required "required") (pred keyword? "keyword")] val-validator})
sourceraw docstring

validator-tupleclj/sdeprecated

(validator-tuple & configs)

Deprecated. Use ::tuple-of metadata instead.

(validator ^::tuple-of [(pred number? "number") [(required "required") (matches #"[0-9]{4,}" "digits")]])

Deprecated. Use ::tuple-of metadata instead.

(validator ^::tuple-of [(pred number? "number") [(required "required") (matches #"[0-9]{4,}" "digits")]])
sourceraw docstring

when-somepclj/s

(when-somep p)

Utility wrapper for transforming functions that you only want called when the value is not nil (i.e. not required).

(make-transformer {:something [(when-somep string/trim) (when-somep string/upper-case)]})

Utility wrapper for transforming functions that you only want called when the
value is not nil (i.e. not required).

(make-transformer {:something [(when-somep string/trim) (when-somep string/upper-case)]})
sourceraw docstring

whenpclj/s

(whenp pred config)

Predicate the usage of a validator config spec. The predicate is called with the same args as the validator. (def validator (whenp < (pred (fn [lesser greater] (< (- greater lesser) 10)) "Second must be within 10 of first"))) (validator 100 1) ;;=> nil (validator 1 5) ;;=> nil (validator 1 100) ;;=> ["Second must be within 10 of first"]

Predicate the usage of a validator config spec. The predicate is called with the same
args as the validator.
(def validator (whenp < (pred (fn [lesser greater] (< (- greater lesser) 10))
                              "Second must be within 10 of first")))
(validator 100 1)
;;=> nil
(validator 1 5)
;;=> nil
(validator 1 100)
;;=> ["Second must be within 10 of first"]
sourceraw docstring

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

× close