The core
namespace provides the two main entry point functions in bouncer:
validate
valid?
All other functions are meant for internal use only and shouldn't be relied upon.
The project README should get you started, it's pretty comprehensive.
If you'd like to know more about the motivation behind bouncer
, check the
announcement post.
The `core` namespace provides the two main entry point functions in bouncer: - `validate` - `valid?` All other functions are meant for internal use only and shouldn't be relied upon. The project [README](https://github.com/leonardoborges/bouncer/blob/master/README.md) should get you started, it's pretty comprehensive. If you'd like to know more about the motivation behind `bouncer`, check the [announcement post](http://www.leonardoborges.com/writings/2013/01/04/bouncer-validation-lib-for-clojure/).
(valid? & args)
Takes a map and one or more validation functions with semantics provided by "validate". Returns true if the map passes all validations. False otherwise.
Takes a map and one or more validation functions with semantics provided by "validate". Returns true if the map passes all validations. False otherwise.
(validate & args)
Takes a
message-fn
(optional) responsible for transforming error metadata into
the validation result (defaults to with-default-messages
)
m
map to be validated
forms
validations to be performed on the map
forms can be a single validator set or a sequence of key/value pairs where:
key ==> :keyword or [:a :path]
value ==> validation-function or validator-set or [[validation-function args+opts]] or [validation-function another-validation-function] or [validation-function [another-validation-function args+opts]]
e.g.:
(core/validate a-map
:name v/required
:age [v/required
[v/number :message "age must be a number"]]
[:passport :number] v/positive)
Returns a vector where the first element is the map of validation errors if any and the second is the original map (possibly) augmented with the errors map.
See also defvalidator
Takes a - `message-fn` (optional) responsible for transforming error metadata into the validation result (defaults to `with-default-messages`) - `m` map to be validated - `forms` validations to be performed on the map forms can be a single validator set or a sequence of key/value pairs where: key ==> :keyword or [:a :path] value ==> validation-function or validator-set or [[validation-function args+opts]] or [validation-function another-validation-function] or [validation-function [another-validation-function args+opts]] e.g.: (core/validate a-map :name v/required :age [v/required [v/number :message "age must be a number"]] [:passport :number] v/positive) Returns a vector where the first element is the map of validation errors if any and the second is the original map (possibly) augmented with the errors map. See also `defvalidator`
(with-default-messages error)
Use together with validate
, e.g.:
(core/validate core/with-default-messages {} :name v/required)
Use together with `validate`, e.g.: (core/validate core/with-default-messages {} :name v/required)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close