Closed jonase closed 8 years ago
This has been changed on #41 so bouncer will behave like this:
user=> (b/validate {} :id [v/string [v/matches #"a*"]])
[nil {}]
user=> (b/validate {} :id [v/required v/string [v/matches #"a*"]])
[{:id ("id must be present")} {:bouncer.core/errors {:id ("id must be present")}}]
I've just released a new version containing this change. Give that a go and let me know if you run into issues.
I'm not sure if this is intended behaviour but
evaluates to
I would have expected the validation to pass since
:id
is notv/required
.If this is expected how do I create a validator where an optional string value must match a regex only if the key exists?
Edit After some digging it's actually
v/string
that makes the key-value non-optional. This was a surprise for me