On 7 April 2011 06:48, Joost <[email protected]> wrote:
> I think your choice of currying makes more sense, at least in the
> context of validations, so it might be a good idea to switch pretzel
> over to that scheme.
Would it make sense for clj-decline?
The Valip predicates are designed with HTML form validation in mind,
so they have a couple of unusual properties:
1. Valip predicates expect to test strings, e.g.
((between 1 10) "5") => true
((between 1 10) "0") => false
2. I'm considering adding an extra :pass return value, to denote the
case when the input string cannot be tested by the predicate. For
instance:
((between 1 10) "foo") => :pass
(integer-string? "foo") => false
This is to ensure I don't get exceptions for predicates when the input
is incorrect:
(defn validate-rating [rating]
(validate rating
[:score present? "should be present"]
[:score digits? "should be a number"]
[:score (between 1 5) "should be between 1 and 5"]))
(validate-rating {:score " "})
=> {:score ["should be present"]}
(validate-rating {:score "foo"})
=> {:score ["should be a number"]}
(validate-rating {:score "15"})
=> {:score ["should be between 1 and 5"]}
So the predicates I'm writing for Valip are somewhat customised for
validating string data, and are not generic predicate functions. Is
Pretzel designed for general-use predicates, or for predicates
designed for form validation?
- James
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en