Merge PR #26: "Validators added: integer, string, boolean, in-range"
Fix cljx warnings
Merge PR #30: "Prepare for 0.3.2 final release``"
Merge PR #29: "Add min-count/max-count"
Merge PR #23: "Added date validator"
(core/valid? {:dt "2014-04-02"} :dt [[v/datetime]])
Merge PR #27: "Cljs support"
This pull request allows users of the library to customise errors messages in a number of different ways. Please see section "Internationalization and advanced error messages" in the README.
This release contains breaking changes: most macros have been removed in favour of pure functions and data structure literals. This means a lot less magic and better composability
core/valid? and core/validate rewritten as functions
remove validators/defvalidatorset macro in favor of standard maps
Update README
Update docstrings
Add email validation
Merge PR #18: "Minor readme change to not make it seem a strange design decision was taken, and very minor (somewhat random) syntax change"
Validator sets can now be used at the top level call to validate and valid?.
(defvalidatorset address-validator
:postcode v/required)
(defvalidatorset person-validator
:name v/required
:age [v/required v/number]
:address address-validator)
(core/validate {} person-validator)
Added tests and a doc section around validation pipelining. It was an undocumented invariant. See discussion here.
(alpha) Validators now support a pre-condition option. If it is met, the validator will run, otherwise it's just skipped:
(core/valid? {:a 1 :b "X"}
:b (v/member #{"Y" "Z"} :pre (comp pos? :a)))
;; false
Fixed Issue #5: "bouncer.validators/member does not allow me to pass it a symbol referring to the collection"
Fixed Issue #7: "3 level composition broken"
defvalidator now lets you define validators with arbitrary number of arguments.
All validators are now implemented using defvalidator
New validators:
member - validates the value is a member of the provided collectionmatches- regex validation (thanks to ghoseb)Updated most validators' docstrings to something less confusing
Added API documentation using marginalia. See the docs folder or this link.
bouncer now stores the error messages in the qualified keyword :bouncer.core/errors (thanks to ghoseb)
For short, just use an alias:
(require '[bouncer.core :as c])
;; then somewhere you want to inspect the errors map
(::c/errors a-map)
short-circuit for validators: if a map entry has multiple validators, it stops at the first failure, moving on to the next map entry.
fixed destructuring bug when using Clojure 1.5 (thanks to Gary Johnson for reporting it)
using leiningen profiles to build against Clojure 1.3, 1.4 and 1.5
defvalidator macro to make defining new validation functions a whole lot simpler.bouncer.validators namespacecustom - for ad-hoc validations using arbitrary functionsvalidatevalidrequirednumberpositiveeveryCan you improve this documentation? These fine people already did:
Leonardo Borges & Filippo DiotaleviEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |