Liking cljdoc? Tell your friends :D

vlad.core


assign-namesclj/s

(assign-names errors selectors-to-names)

translate expects each field to have a human readable name. assign-names takes a collection of errors and a map of selectors to names and will return the errors with names inserted.

`translate` expects each field to have a human readable name. `assign-names`
takes a collection of errors and a map of selectors to names and will return
the errors with names inserted.
sourceraw docstring

attrclj/s

(attr selector)
(attr selector validation)

Runs a validation on the data found at selector. If there are nested uses of attr any :selector attributes in errors will be updated to reflect the full selector.

Example:

(validate (attr [:name] (present)) {:name "Vlad"})

Runs a validation on the data found at `selector`. If there are nested uses
of `attr` any `:selector` attributes in errors will be updated to reflect the
full `selector`.

Example:

(validate (attr [:name] (present)) {:name "Vlad"})
sourceraw docstring

Attrcljs

source

Chaincljs

source

chainclj/s

(chain)
(chain left)
(chain left right)
(chain left right & validations)

Example:

(attr :password (chain (present) (length-over 7))

Example:

(attr :password
  (chain
    (present)
    (length-over 7))
sourceraw docstring

english-translationclj/smultimethod

Takes an error and returns a human readable version of it.

Takes an error and returns a human readable version of it.
sourceraw docstring

equals-fieldclj/s

(equals-field first-selector second-selector)
(equals-field first-selector second-selector error-data)

Checks that the values found at each of your selectors are equal to each other

Checks that the values found at each of your selectors are equal to each
other
sourceraw docstring

equals-valueclj/s

(equals-value value)
(equals-value value error-data)

Checks that the value is equal to the value that you provide.

Checks that the value is equal to the `value` that you provide.
sourceraw docstring

field-errorsclj/s

(field-errors validations data)
source

flat-errorsclj/s

(flat-errors validations data)
source

guess-field-namesclj/s

(guess-field-names errors)

Will convert selectors to strings by swapping hyphens for spaces and capitalising.

Will convert selectors to strings by swapping hyphens for spaces and
capitalising.
sourceraw docstring

joinclj/s

(join)
(join left)
(join left right)
(join left right & validations)

Example:

(join (attr :name (present)) (attr :age (present)))

Example:

(join
  (attr :name (present))
  (attr :age (present)))
sourceraw docstring

Joincljs

source

length-inclj/s

(length-in lower upper)
(length-in lower upper error-data)

Checks that the count of the value is over lower and under upper. No checking is done that lower is lower than upper. This validator may return multiple errors

Checks that the `count` of the value is over `lower` and under `upper`. No
checking is done that `lower` is lower than `upper`. This validator may
return multiple errors
sourceraw docstring

length-overclj/s

(length-over size)
(length-over size error-data)

Checks that the count of the value is over size.

Checks that the `count` of the value is over `size`.
sourceraw docstring

length-underclj/s

(length-under size)
(length-under size error-data)

Checks that the count of the value is under size.

Checks that the `count` of the value is under `size`.
sourceraw docstring

matchesclj/s

(matches pattern)
(matches pattern error-data)

Checks that the value is a regex match for pattern. This uses clojure's re-matches function which may not behave as you expect. Your pattern will have to match the whole string to count as a match.

Checks that the value is a regex match for `pattern`.  This uses clojure's
`re-matches` function which may not behave as you expect.  Your pattern will
have to match the whole string to count as a match.
sourceraw docstring

not-ofclj/s

(not-of set)
(not-of set error-data)

Checks that the value is not found within set

Checks that the value is not found within `set`
sourceraw docstring

one-ofclj/s

(one-of set)
(one-of set error-data)

Checks that the value is found within set

Checks that the value is found within `set`
sourceraw docstring

predicateclj/s

(predicate pred information)
(predicate selector pred information)

Examples: (predicate #(> size (count %)) {:type ::length-over :size size})

(predicate [:user :password] #(> size (count %)) {:type ::length-over :size size})

Examples:
(predicate #(> size (count %))
           {:type ::length-over :size size})

(predicate [:user :password]
           #(> size (count %))
           {:type ::length-over :size size})
sourceraw docstring

Predicatecljs

source

presentclj/s

(present)
(present error-data)
source

translate-errorsclj/s

(translate-errors errors translation)

Translates a sequence of errors into a map of plain english error messages. Selectors are used as keys. The error message may be overwritten by setting the :message key in your error map.

Example:

(translate-errors [{ :type :vlad.core/length-under :selector [:password] :name "Password" :size 8}]) ; => {[:password] "Password must be under 8 characters long."}

Translates a sequence of errors into a map of plain english error messages.
Selectors are used as keys. The error message may be overwritten by setting
the :message key in your error map.

 Example:

  (translate-errors [{
    :type :vlad.core/length-under
    :selector [:password]
    :name "Password"
    :size 8}])
  ; => {[:password] "Password must be under 8 characters long."}
sourceraw docstring

validclj/s

(valid data)

valid is a validation that does nothing. It can be safely composed with other validations. It is used as the identity value for reducers/monoid functions (Don't panic. You don't need to know what that means to use vlad).

`valid` is a validation that does nothing. It can be safely composed with
other validations. It is used as the identity value for reducers/monoid
functions (Don't panic. You don't need to know what that means to use vlad).
sourceraw docstring

valid?clj/s

(valid? validations data)
source

Validationclj/s≠protocol

The core of vlad is the Validation protocol. It simply requires that your validation type knows how to run against some data. Implementations of validate should return a sequence of errors. An error may be anything but is generally of the form {:type ::something :some-extra-data 123}.

The core of vlad is the `Validation` protocol. It simply requires that your
validation type knows how to run against some data. Implementations of
`validate` should return a sequence of errors. An error may be anything but
is generally of the form `{:type ::something :some-extra-data 123}`.

validateclj/s

(validate self data)
sourceraw docstring

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

× close