vlad documentation

assign-name

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

chain

(chain)(chain left)(chain left right)(chain left right & validations)
Example:

(chain
  (present "Password" :password)
  (length_over 7 "Password" :password))

english-translation

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

equals-field

(equals-field first-selector second-selector)
Checks that the values found at each of your selectors are equal to each
other

equals-value

(equals-value value selector)
Checks that the value found at `selector` is equal to the `value` that you
provide.

join

(join)(join left)(join left right)(join left right & validations)
Example:

(join
  (present "Name" :name)
  (present "Age" :age))

length-in

(length-in lower upper selector)
Checks that the `count` of the value found at `selector` is over `lower` and
under `upper`. No checking is done that `lower` is lower than `upper`. This
validator may return multiple errors

length-over

(length-over size selector)
Checks that the `count` of the value found at `selector` is over `size`.

length-under

(length-under size selector)
Checks that the `count` of the value found at `selector` is under `size`.

matches

(matches pattern selector)
Checks that the value found at `selector` 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 found at `selector` to count
as a match.

not-of

(not-of set selector)
Checks that the value found at `selector` is not found within `set`

one-of

(one-of set selector)
Checks that the value found at `selector` is found within `set`

predicate

(predicate selector predicate information)
Example:

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

present

(present selector)
Checks that the string found at `selector` is not blank.

Example:

  (validate (present :name)
            {:name "Vlad"})

translate-errors

(translate-errors errors translation)
Translates a sequence of errors into a map of plain english error messages.
Selectors are used as keys.

Example:

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

validate

(validate self data)