Liking cljdoc? Tell your friends :D

clova.core

The core namespace contains all of the built in validators and the defvalidator macro.

The only other public functions are

  • validation-set
  • validate
  • valid?
  • results
  • as-validator

You can view more information in the [readme] (https://github.com/markwoodhall/clova/blob/master/README.md). There are also example validation scenarios here.

The API documentation is available here.

You can also view [blog posts] (http://markw.xyz/tags/clova/) about clova.

The core namespace contains all of the built in validators and the
defvalidator macro.

The only other public functions are

- `validation-set`
- `validate`
- `valid?`
- `results`
- `as-validator`

You can view more information in the [readme] (https://github.com/markwoodhall/clova/blob/master/README.md).
There are also example validation scenarios [here](http://markwoodhall.github.io/clova/EXAMPLES.html).

The API documentation is available [here](http://markwoodhall.github.io/clova/).

You can also view [blog posts] (http://markw.xyz/tags/clova/) about clova.
raw docstring

=?clj/s

(=? value v)

Check an input value to see if it is equal to v using the regular = function.

It is worthwhile using =date? for validating date equality, since it has support for parsing string dates and comparing DateTime objects.

Check an input value to see if it is equal to v using the regular `=` function.

It is worthwhile using [[=date?]] for validating date equality, since it has support
for parsing string dates and comparing DateTime objects.
sourceraw docstring

=date?clj/s

(=date? value d & [opt])

Check an input value to see if it is chronoligically equal to d. Where d is either the string representation of a date or one of [java.util.Date org.joda.time.DateTime] or [js/Date goog.date.Date goog.date.DateTime]

Optionally, takes a map argument and makes use of the following keys:

  • :formatter You can use one of the built in ISO8601 formatters from clj-time or cljs-time. You can also define your own custom format string.
Check an input value to see if it is chronoligically equal to d. Where
d is either the string representation of a date or one of `[java.util.Date org.joda.time.DateTime]` or
`[js/Date goog.date.Date goog.date.DateTime]`

Optionally, takes a map argument and makes use of the following keys:

- `:formatter` You can use one of the built in ISO8601 formatters
from clj-time or cljs-time. You can also define your own custom format string.
sourceraw docstring

after?clj/s

(after? value d & [opt])

Check an input value to see if it is chronoligically after d. Where d is either the string representation of a date or one of [java.util.Date org.joda.time.DateTime] or [js/Date goog.date.Date goog.date.DateTime]

Optionally, takes a map argument and makes use of the following keys:

  • :formatter You can use one of the built in ISO8601 formatters from clj-time or cljs-time. You can also define your own custom format string.
Check an input value to see if it is chronoligically after d. Where
d is either the string representation of a date or one of `[java.util.Date org.joda.time.DateTime]` or
`[js/Date goog.date.Date goog.date.DateTime]`

Optionally, takes a map argument and makes use of the following keys:

- `:formatter` You can use one of the built in ISO8601 formatters
from clj-time or cljs-time. You can also define your own custom format string.
sourceraw docstring

all?clj/s

(all? value col)

Check an input value to see if it matches a given collection of predicates. Predicates can be concrete values or they can be functions, they can be single items or collections.

(all? true [true (fn [v] (= true v))]) (all? true (fn [v] (= true v)))

Check an input value to see if it matches a given collection
of predicates. Predicates can be concrete values or they can be functions, they
can be single items or collections.

`(all? true [true (fn [v] (= true v))])`
`(all? true (fn [v] (= true v)))`
sourceraw docstring

alphanumeric?clj/s

(alphanumeric? value)

Checks an input value to see if it is alphanumeric. Alphanumeric is defined as [a-zA-Z0-9*$], if you need to customise this you can use the matches? validator with a custom regex.

Checks an input value to see if it is alphanumeric. Alphanumeric
is defined as `[a-zA-Z0-9*$]`, if you need to customise this you can use the
[[matches?]] validator with a custom regex.
sourceraw docstring

as-validatorclj/s

(as-validator f)
(as-validator f
              {:keys [default-message allow-missing-key?]
               :or {default-message "%s is %s but this is not a valid value."
                    allow-missing-key? true}
               :as m})

Takes a function f and applies optional m as meta data around it. f should be accept a first argument as the value to validate.

When m is present the following keys are taken and used as meta data to declare a validator:

  • :default-message The default message template to be used when validation fails.
  • :allow-missing-key? Should validation fail if the :target key is not present.

When m is not specified suitable defaults are used.

Takes a function f and applies optional m as meta data around it. f should be accept
a first argument as the value to validate.

When m is present the following keys are taken and used as meta data to declare a validator:

- `:default-message` The default message template to be used when validation fails.
- `:allow-missing-key?` Should validation fail if the `:target` key is not present.

When m is not specified suitable defaults are used.
sourceraw docstring

before?clj/s

(before? value d & [opt])

Check an input value to see if it is chronoligically before d. Where d is either the string representation of a date or one of [java.util.Date org.joda.time.DateTime] or [js/Date goog.date.Date goog.date.DateTime]

Optionally, takes a map argument and makes use of the following keys:

  • :formatter You can use one of the built in ISO8601 formatters from clj-time or cljs-time. You can also define your own custom format string.
Check an input value to see if it is chronoligically before d. Where
d is either the string representation of a date or one of `[java.util.Date org.joda.time.DateTime]` or
`[js/Date goog.date.Date goog.date.DateTime]`

Optionally, takes a map argument and makes use of the following keys:

- `:formatter` You can use one of the built in ISO8601 formatters
from clj-time or cljs-time. You can also define your own custom format string.
sourceraw docstring

between?clj/s

(between? value lower upper)

Checks an input value to see if it is between lower and upper.

Checks an input value to see if it is between lower and upper.
sourceraw docstring

credit-card?clj/s

(credit-card? value)

Chacks an input value to see if it is a "valid" credit card number based on the Luhn algorithm.

Chacks an input value to see if it is a "valid" credit
card number based on the Luhn algorithm.
sourceraw docstring

date?clj/s

(date? value & [opt])

Checks an input value to see if it is a date.

If value is a string then it is parsed using clj-time or cljs-time.

If value is not a string but is one of [java.util.Date org.joda.time.DateTime] or [js/Date goog.date.Date goog.date.DateTime] then it will be considered a date?.

Optionally, takes a map argument and makes use of the following keys:

  • :formatter You can use one of the built in ISO8601 formatters from clj-time or cljs-time. You can also define your own custom format string.
Checks an input value to see if it is a date.

If value is a string then it is parsed using `clj-time` or `cljs-time`.

If value is not a string but is one of `[java.util.Date org.joda.time.DateTime]` or
`[js/Date goog.date.Date goog.date.DateTime]` then it will be considered a `date?`.

Optionally, takes a map argument and makes use of the following keys:

- `:formatter` You can use one of the built in ISO8601 formatters
from clj-time or cljs-time. You can also define your own custom format string.
sourceraw docstring

defvalidatorclj/smacro

(defvalidator doc-string fname validator-meta-data args & body)

Wraps body in a function and defines it with meta data used to support the validation process. Works using a similar pattern to defn.

Wraps body in a function and defines it with meta data
used to support the validation process.
Works using a similar pattern to `defn`.
sourceraw docstring

email?clj/s

(email? value)

Checks an input value to see if it is a valid email address

Checks an input value to see if it is a valid email address
sourceraw docstring

exists?clj/s

(exists? value col)

Checks for the presence of an item in a collection.

Checks for the presence of an item in a collection.
sourceraw docstring

greater?clj/s

(greater? value lower)

Checks an input value to see if it is greater than lower.

Checks an input value to see if it is greater than lower.
sourceraw docstring

length?clj/s

(length? value l)

Check an input value to see if it has a length equal to l. Work on sequences and strings.

Check an input value to see if it has a length equal to l.
Work on sequences and strings.
sourceraw docstring

lesser?clj/s

(lesser? value lower)

Checks an input value to see if it is less than lower.

Checks an input value to see if it is less than lower.
sourceraw docstring

longer?clj/s

(longer? value l)

Check an input value to see if it has a length longer than l. Work on sequences and strings.

Check an input value to see if it has a length longer than l.
Work on sequences and strings.
sourceraw docstring

matches?clj/s

(matches? value regex)

Checks a string representation of value against regex and returns true if value matches the regex. If value is not a match then returns nil.

Checks a string representation of value against regex and
returns true if value matches the regex. If value is not a
match then returns nil.
sourceraw docstring

negative?clj/s

(negative? value)

Checks an input value to see if it is a negative number.

Checks an input value to see if it is a negative number.
sourceraw docstring

not-empty?clj/s

(not-empty? value)

Checks for the presence of an empty string.

Checks for the presence of an empty string.
sourceraw docstring

not-exists?clj/s

(not-exists? value col)

Checks for the non presence of an item in a collection.

Checks for the non presence of an item in a collection.
sourceraw docstring

not-nil?clj/s

(not-nil? value)

Checks for the presence of a non nil value.

Checks for the presence of a non nil value.
sourceraw docstring

numeric?clj/s

(numeric? value)

Checks an input value to see if it is numeric.

Checks an input value to see if it is numeric.
sourceraw docstring

one-of?clj/s

(one-of? value col)

Checks an input value to see if it is one of the items in a col

Checks an input value to see if it is one of the items in a col
sourceraw docstring

positive?clj/s

(positive? value)

Checks an input value to see if it is a positive number.

Checks an input value to see if it is a positive number.
sourceraw docstring

post-code?clj/s

(post-code? value)

Checks an input value to see if it is a valid uk post code.

Checks an input value to see if it is a valid uk post code.
sourceraw docstring

required?clj/s

(required? value)

Checks for the presence of a key based on the default value of ::key-not-found? for a missing key.

Checks for the presence of a key based on the default value of `::key-not-found?`
for a missing key.
sourceraw docstring

resultsclj/s

(results v-set m)

Takes a validation set and applies it to m. This is just a shorthand method over the validate function and returns only the validation results.

Takes a validation set and applies it to m.
This is just a shorthand method over the validate function and returns
only the validation results.
sourceraw docstring

shorter?clj/s

(shorter? value l)

Check an input value to see if it has a length shorter than l. Work on sequences and strings.

Check an input value to see if it has a length shorter than l.
Work on sequences and strings.
sourceraw docstring

stringy?clj/s

(stringy? value)

Checks an input value to see if it is a string

Checks an input value to see if it is a string
sourceraw docstring

url?clj/s

(url? value)

Checks an input value to see if it is a valid url.

Checks an input value to see if it is a valid url.
sourceraw docstring

valid?clj/s

(valid? v-set m)

Takes a validation set and applies it to m. This is just a shorthand method over the validate function and returns only a truthy or falsy value indicating the validation status.

Takes a validation set and applies it to m.
This is just a shorthand method over the validate function and returns
only a truthy or falsy value indicating the validation status.
sourceraw docstring

validateclj/s

(validate v-set m)
(validate v-set
          m
          {:keys [default-message-fn short-circuit? defaults only-failures?]
           :or {default-message-fn (fn [v-type value args target default] nil)
                short-circuit? false
                defaults {}
                only-failures? false}})

Takes a validation set and applies it to m. Returns the original map m transposed with error messages for non validating keys, also adds :clova.core/valid? with either a truthy or falsy value and :clova.core/results which is a sequence of validation failure messages, if applicable.

Optionally takes a map of options:

:default-message-fn can be specified to override the default validation messages. If specified the function will be called and receive the validator type as an argument. If the result of calling the function is anything but nil it will be used as the default validation message.

:short-circuit? when true no further validators for the validation set will be processed. The default is false and therefore to process all validators.

Takes a validation set and applies it to m.
Returns the original map m transposed with error messages for non validating keys, also adds `:clova.core/valid?` with either a truthy or falsy value and
`:clova.core/results` which is a sequence of validation failure messages, if applicable.

Optionally takes a map of options:

`:default-message-fn` can be specified to override the default validation messages. If specified
the function will be called and receive the validator type as an argument. If the result of calling
the function is anything but nil it will be used as the default validation message.

`:short-circuit?` when true no further validators for the validation set will be processed.
The default is false and therefore to process all validators.
sourceraw docstring

validation-setclj/s

(validation-set col)
(validation-set col {:keys [key-fn]})

Takes a sequence (col) that represents keys to validate and the functions used to validate them.

e.g. [:email email? :post-code post-code?]

It is also possible to specify keys to traverse nested maps.

e.g. using [[:user :credentials :name] [matches? #"someregex"]] we can define a validation function to target the :name key in a map like {:user {:credentials {:name "username" }}}

Returns a sequence of functions merged with meta data used by the validation.

Takes a sequence (col) that represents
keys to validate and the functions used to validate them.

e.g. `[:email email? :post-code post-code?]`

It is also possible to specify keys to traverse nested maps.

e.g. using `[[:user :credentials :name] [matches? #"someregex"]]`
we can define a validation function to target the `:name` key in a map like
`{:user {:credentials {:name "username" }}}`

Returns a sequence of functions merged with meta data used by
the validation.
sourceraw docstring

zip-code?clj/s

(zip-code? value)

Checks an input value to see if it is a valid zip code.

Checks an input value to see if it is a valid zip code.
sourceraw docstring

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

× close