I noticed I hadn't addressed this question earlier, so.

On Apr 9, 3:48 am, James Reeves <jree...@weavejester.com> wrote:

> The problem I have with such a scheme is that it seems more complex to
> use in practise. For instance, let's say I wanted an optional value.
> If predicates that fail a precondition return a truthy value (such as
> :pass) I could write:
>
>   (defn validate-rating [rating]
>     (validate rating
>       [:score integer-string? "must be an integer"]
>       [:score (between 1 10) "must be between 1 and 10"]))
>
> This would not return an error if the :score field was left blank,
> because integer-string? and (between 1 10) would return :pass for an
> empty string.
>
> How would you do this in clj-decline?

I wouldn't, directly. There's no way to know that this or is not an
error in the input, without the programmers' assistance. clj-decline
currently only has "everything must validate" and "no validation must
fail" strategies, but it should not be a big deal to add a strategy
like "if this predicate (NOT a validation) is true, run these
validations, otherwise, accept".

I still maintain that this should not be part of basic predicates/
tests.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to