Liking cljdoc? Tell your friends :D

examine.core

Function for creation of rule-sets, validating, and using validation results

Function for creation of rule-sets, validating, and using validation results
raw docstring

constraint-or-condition?clj/s

(constraint-or-condition? x)

Returns true if x is either a function or a vector [fn alternative-message].

Returns true if x is either a function or a vector [fn
alternative-message].
sourceraw docstring

has-errors?clj/s

(has-errors? validation-results)

Returns true if the validation results contain at least one not-nil message.

Returns true if the validation results contain at least
one not-nil message.
sourceraw docstring

map-data-providerclj/s

(map-data-provider m keyword-or-vector)

Default data provider that uses get or get-in to retrieve data from a map/record.

Default data provider that uses get or get-in to retrieve
data from a map/record.
sourceraw docstring

messagesclj/s

(messages validation-results)
(messages localizer-fn validation-results)

Returns a map {path -> sequence-of-human-readable-strings}. If the localizer-fn is not given the default-localizer is used.

Returns a map {path -> sequence-of-human-readable-strings}.
If the localizer-fn is not given the default-localizer is used.
sourceraw docstring

messages-forclj/s

(messages-for path validation-results)
(messages-for localizer-fn path validation-results)

Returns a sequence of human readable strings for the given path. If the localizer-fn is not given the default-localizer is used.

Returns a sequence of human readable strings for the given path.
If the localizer-fn is not given the default-localizer is used.
sourceraw docstring

rule-setclj/s

(rule-set & specs)

Creates a rule-set from paths, constraints and conditions.

The general structure of specs is: path constraints-and-conditions+ path constraints-and-conditions+

A path points to data. It can either be a key, or a vector containing keys. n paths are grouped by a vector to specify multiple data locations that apply to n-arg constraints.

Examples: :foo Specifies a path to value in {:foo value} [:foo :bar] Specifies 2 paths to values in {:foo value1 :bar value2} [[:foo :bar]] Specifies a single path pointing to value in {:foo {:bar value}} [:foo [:bar :baz :bum]] Specifies 2 paths in {:foo value1 :bar {:baz {:bum value2}}}

Constraints are 1-arg functions that return a string to flag a constraint violation for the given value or nil otherwise.

Conditions are 1-arg predicates returning true or false that stop application of subsequent constraints after returning false.

Example: (rule-set :foo required (min-length 3) [[:bar :baz]] number? (in-range 0 10))

Creates a rule-set from paths, constraints and conditions.

The general structure of `specs` is:
  path constraints-and-conditions+
  path constraints-and-conditions+

A path points to data. It can either be a key, or a vector
containing keys. n paths are grouped by a vector to specify
multiple data locations that apply to n-arg constraints.

Examples:
:foo
   Specifies a path to value in {:foo value}
[:foo :bar]
  Specifies 2 paths to values in {:foo value1 :bar value2}
[[:foo :bar]]
   Specifies a single path pointing to value in {:foo {:bar value}}
[:foo [:bar :baz :bum]]
   Specifies 2 paths in {:foo value1 :bar {:baz {:bum value2}}}

Constraints are 1-arg functions that return a string to flag
a constraint violation for the given value or nil otherwise.

Conditions are 1-arg predicates returning true or false that stop
application of subsequent constraints after returning false.

Example:
  (rule-set :foo required (min-length 3)
            [[:bar :baz]] number? (in-range 0 10))
sourceraw docstring

sub-setclj/s

(sub-set rule-set & ps)

Returns the subset of the rule-set that contains only those rules that reference at least one of the paths given in ps.

Returns the subset of the rule-set that contains only those
rules that reference at least one of the paths given in ps.
sourceraw docstring

updateclj/s

(update old-map new-map)

Takes two validation results (or any map) and recursively updates the first with all values of the second. Existing values of the first are kept.

Takes two validation results (or any map) and recursively updates
the first with all values of the second. Existing values of the
first are kept.
sourceraw docstring

validateclj/s

(validate rule-set data)
(validate data-provider rule-set data)

Creates validation results by applying the constraints of the rule-set to the data. If the data-provider arg is missing the map-data-provider is used.

Creates validation results by applying the constraints of the rule-set
to the data. If the data-provider arg is missing the map-data-provider
is used.
sourceraw docstring

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

× close