Liking cljdoc? Tell your friends :D

mississippi.core


email-regexclj

source

errorsclj

(errors subject validations)
source

errors-forclj

(errors-for subject attr validations)
source

in-rangeclj

(in-range start end & {msg :msg when-fn :when})

Validates the value v falls between the range of start and end.

Validates the value v falls between the range of start and end.
sourceraw docstring

matchesclj

(matches re & {msg :msg when-fn :when match-fn :match-fn})

Validates the String value v matches the given Regexp re. Takes an optional match-fn, defaulting to re-find.

Validates the String value v matches the given Regexp re. Takes an
optional match-fn, defaulting to re-find.
sourceraw docstring

matches-emailclj

(matches-email & {msg :msg when-fn :when})

Validates the String value v matches a basic email pattern.

Validates the String value v matches a basic email pattern.
sourceraw docstring

member-ofclj

(member-of s & {msg :msg when-fn :when})

Validates the value v is contained in s (will be coerced to a set).

Validates the value v is contained in s (will be coerced to a set).
sourceraw docstring

numericclj

(numeric & {msg :msg when-fn :when})

Validates given value is an instance of Number.

Validates given value is an instance of Number.
sourceraw docstring

requiredclj

(required & {msg :msg when-fn :when})
source

subset-ofclj

(subset-of s & {msg :msg when-fn :when})

Validates the value v is a subset of s. Both v and s will be coerced to sets.

Validates the value v is a subset of s. Both v and s will be coerced to sets.
sourceraw docstring

valid?clj

(valid? resource)

Checks if the map contains any errors

Checks if the map contains any errors
sourceraw docstring

validateclj

(validate subject validations)

Apply a map of validations to a Clojure map.

Validations should be a map where the key is the attribute in the subject map to be validated and the value is a vector of validation information to apply to the value in the subject map.

Validation data should be in the following format. The first element is a function accepting a single arugment and returning a boolean indicating if the value is valid. Subsequent values should be pairs of options. Valid options are:

:when a predicate function, accepting the subject under test, and returning if the validation should be applied :msg either a string or a function used the message when the validation fails. If a function accepts a single argument of the value being validated

For example, given a subject of:

{:a "some string"}

A possible validations map could be:

{:a [(comp not nil?) :msg "you forgot to supply a value"] }

A number of builders for common validations have been provided they accept the same options and are applied in the same way.

In the example above the validation could be replaced by:

{:a (required :msg "you forgot to supply a value")]}

Multiple validations can be provided by supplying a vector of vectors containing validation data. For example for the subject:

{:a 1}

A possible validation map could be

{:a [(required) (numeric)]}

The function returns a map containing the messages of the validation failures or an empty map. For example:

(errors {:a nil} {:a (required)}

Returns

{:a ["required"]}

To validate nested maps, simply mirror the subject's shape in the validations:

(validate {:a {:b {:c "foo"}}} {:a {:b {:c [(required)]}}})

An alternative syntax for validating nested attributes is to provide the key as a vector of keys:

{[:a :b :c] [(required)]}

Apply a map of validations to a Clojure map.

Validations should be a map where the key is the attribute in the
subject map to be validated and the value is a vector of
validation information to apply to the value in the subject map.

Validation data should be in the following format. The first
element is a function accepting  a single arugment and returning a
boolean indicating if the value is valid. Subsequent values should be
pairs of options. Valid options are:

 :when  a predicate function, accepting the subject under test, and returning
        if the validation should be applied
 :msg   either a string or a function used the message when the validation fails.
        If a function accepts a single argument of the value being validated

For example, given a subject of:

{:a "some string"}

A possible validations map could be:

{:a [(comp not nil?) :msg "you forgot to supply a value"] }

A number of builders for common validations have been provided they accept
the same options and are applied in the same way.

In the example above the validation could be replaced by:

{:a (required :msg "you forgot to supply a value")]}

Multiple validations can be provided by supplying a vector of vectors containing
validation data. For example for the subject:

{:a 1}

A possible validation map could be

{:a [(required) (numeric)]}

The function returns a map containing the messages of the validation failures or an
empty map. For example:

(errors {:a nil} {:a (required)}

Returns

{:a ["required"]}

To validate nested maps, simply mirror the subject's shape in the validations:

(validate {:a {:b {:c "foo"}}}
          {:a {:b {:c [(required)]}}})

An alternative syntax for validating nested attributes is to provide
the key as a vector of keys:

{[:a :b :c] [(required)]}
sourceraw docstring

wrap-nillableclj

(wrap-nillable [validation-fn & opts])

Wrap around vector with validation function if desired

Wrap around vector with validation function if desired
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close