Re: ANN: bouncer, validation library for clojure

2013-01-15 Thread Leonardo Borges
Excellent.

I'll push 0.2.2 final to clojars soon - as soon as I get the ANN email out.

Thanks for the help.

Cheers

Leonardo Borges
www.leonardoborges.com


On Wed, Jan 16, 2013 at 4:37 AM, Gary Johnson  wrote:

> Worked like a charm. Thanks.
>
>
> On Tuesday, January 15, 2013 12:33:26 PM UTC-5, Gary Johnson wrote:
>>
>> Right, I was testing against 1.5.0-RC1 and 1.5.0-RC2. Same problem
>> occurred both times. I should have reported that in my initial bug report.
>> Sorry about that. Also, thanks for the quick turnaround. I'll pull it and
>> test it out.
>>
>>   ~Gary
>>
>> On Monday, January 14, 2013 7:16:29 PM UTC-5, Leonardo Borges wrote:
>>>
>>> Sean pointed me to it in the other thread. I read the ticket and
>>> discussion - I personally don't feel it's abuse. To me it feels as natural
>>> a use of destructuring as any other.
>>>
>>> just my 2c.
>>>
>>> Leonardo Borges
>>> www.leonardoborges.com
>>>
>>>
>>> On Tue, Jan 15, 2013 at 11:14 AM, Toby Crawley wrote:
>>>
 This issue has already been reported and filed:
 http://dev.clojure.org/jira/**browse/CLJ-1140

 There's been some discussion around that issue on clojure-dev@ as to
 whether this is a regression or an abuse of destructuring.

 Leonardo Borges writes:

 > Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure
 whether this
 > is a regression or intended behaviour so I'll send a separate email
 to the
 > list about that.
 >


 --
 Toby Crawley
 http://immutant.org | http://torquebox.org

 --
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@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+u...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=en

>>>
>>>  --
> 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
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-15 Thread Gary Johnson
Worked like a charm. Thanks.

On Tuesday, January 15, 2013 12:33:26 PM UTC-5, Gary Johnson wrote:
>
> Right, I was testing against 1.5.0-RC1 and 1.5.0-RC2. Same problem 
> occurred both times. I should have reported that in my initial bug report. 
> Sorry about that. Also, thanks for the quick turnaround. I'll pull it and 
> test it out.
>
>   ~Gary
>
> On Monday, January 14, 2013 7:16:29 PM UTC-5, Leonardo Borges wrote:
>>
>> Sean pointed me to it in the other thread. I read the ticket and 
>> discussion - I personally don't feel it's abuse. To me it feels as natural 
>> a use of destructuring as any other.
>>
>> just my 2c.
>>
>> Leonardo Borges
>> www.leonardoborges.com
>>
>>
>> On Tue, Jan 15, 2013 at 11:14 AM, Toby Crawley wrote:
>>
>>> This issue has already been reported and filed:
>>> http://dev.clojure.org/jira/browse/CLJ-1140
>>>
>>> There's been some discussion around that issue on clojure-dev@ as to
>>> whether this is a regression or an abuse of destructuring.
>>>
>>> Leonardo Borges writes:
>>>
>>> > Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether 
>>> this
>>> > is a regression or intended behaviour so I'll send a separate email to 
>>> the
>>> > list about that.
>>> >
>>>
>>>
>>> --
>>> Toby Crawley
>>> http://immutant.org | http://torquebox.org
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>>
>>
>>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-15 Thread Gary Johnson
Right, I was testing against 1.5.0-RC1 and 1.5.0-RC2. Same problem occurred 
both times. I should have reported that in my initial bug report. Sorry 
about that. Also, thanks for the quick turnaround. I'll pull it and test it 
out.

  ~Gary

On Monday, January 14, 2013 7:16:29 PM UTC-5, Leonardo Borges wrote:
>
> Sean pointed me to it in the other thread. I read the ticket and 
> discussion - I personally don't feel it's abuse. To me it feels as natural 
> a use of destructuring as any other.
>
> just my 2c.
>
> Leonardo Borges
> www.leonardoborges.com
>
>
> On Tue, Jan 15, 2013 at 11:14 AM, Toby Crawley 
> 
> > wrote:
>
>> This issue has already been reported and filed:
>> http://dev.clojure.org/jira/browse/CLJ-1140
>>
>> There's been some discussion around that issue on clojure-dev@ as to
>> whether this is a regression or an abuse of destructuring.
>>
>> Leonardo Borges writes:
>>
>> > Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether 
>> this
>> > is a regression or intended behaviour so I'll send a separate email to 
>> the
>> > list about that.
>> >
>>
>>
>> --
>> Toby Crawley
>> http://immutant.org | http://torquebox.org
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Sean pointed me to it in the other thread. I read the ticket and discussion
- I personally don't feel it's abuse. To me it feels as natural a use of
destructuring as any other.

just my 2c.

Leonardo Borges
www.leonardoborges.com


On Tue, Jan 15, 2013 at 11:14 AM, Toby Crawley  wrote:

> This issue has already been reported and filed:
> http://dev.clojure.org/jira/browse/CLJ-1140
>
> There's been some discussion around that issue on clojure-dev@ as to
> whether this is a regression or an abuse of destructuring.
>
> Leonardo Borges writes:
>
> > Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether
> this
> > is a regression or intended behaviour so I'll send a separate email to
> the
> > list about that.
> >
>
>
> --
> Toby Crawley
> http://immutant.org | http://torquebox.org
>
> --
> 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
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Toby Crawley
This issue has already been reported and filed:
http://dev.clojure.org/jira/browse/CLJ-1140

There's been some discussion around that issue on clojure-dev@ as to
whether this is a regression or an abuse of destructuring.

Leonardo Borges writes:

> Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether this
> is a regression or intended behaviour so I'll send a separate email to the
> list about that.
>


-- 
Toby Crawley
http://immutant.org | http://torquebox.org

-- 
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


Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Alright so the bug appears in Clojure 1.5.0-RC1 - I'm not sure whether this
is a regression or intended behaviour so I'll send a separate email to the
list about that.

In the meantime I've applied a fix and pushed [bouncer "0.2.2-RC2"]

With this change I'm also using lein profiles to run the tests against
Clojure 1.3, 1.4 and 1.5-RC1 - The README has a build status indicator from
travis.ci. This should prevent version bugs like this one from appearing in
the future.

Thanks for the report,
Cheers

Leonardo Borges
www.leonardoborges.com


On Tue, Jan 15, 2013 at 9:51 AM, Leonardo Borges <
leonardoborges...@gmail.com> wrote:

> Hi Gary,
>
> Thanks for the bug report.
>
> Which version of Clojure causes the issue? I've been using Clojure 1.4 and
> the exact snippet you posted works flawlessly. As well as bouncer, given I
> have test cases around validators with no explicit messages.
>
>
> Cheers,
>
> Leonardo Borges
> www.leonardoborges.com
>
>
> On Tue, Jan 15, 2013 at 7:52 AM, Gary Johnson  wrote:
>
>> Hey Leonardo,
>>
>>   There's a critical bug in 0.2.2-RC1 in the bouncers.core/wrap function.
>> An IllegalArgumentException is triggered whenever a validator is not passed
>> an explicit :message field. It looks like this was introduced in the
>> process of trying to allow validators to take an arbitrary number of input
>> args (a very good thing IMO). Here's a minimum case for replicating this
>> error at your repl:
>>
>> (let [{:keys [message] :or {message "foo"}} '()] message)
>> IllegalArgumentException No value supplied for key: null
>> clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
>>
>> This is being triggered in your wrap function when you apply map
>> destructuring to the right-hand result of (split-with (complement keyword?)
>> args). Anyway, here is a patched version of wrap that should fix the
>> problem. FWIW, I also fixed the docstring typo "erros" -> "errors".
>>
>> (defn wrap
>>   "Wraps pred in the context of validating a single value
>>
>>   - `acc`  is the map being validated
>>
>>   - `pred` is a validator
>>
>>   - `k`the path to the value to be validated in the associative
>> structure acc
>>
>>   - `args` any extra args to pred
>>
>>   It only runs pred if:
>>
>>   - the validator is optional *and* there is a non-nil value to be
>> validated (this information is read from pred's metadata)
>>
>>   - there are no previous errors for the given path
>>
>>   Returns `acc` augmented with a namespace qualified ::errors keyword
>> "
>>   [acc [pred k & args]]
>>   (let [pred (h/resolve-or-same pred)
>> k (if (vector? k) k [k])
>> error-path (cons ::errors k)
>> {:keys [default-message-format optional]} (meta pred)
>> [args message-kv] (split-with (complement keyword?) args)
>> message (get (apply hash-map message-kv) :message
>> default-message-format)
>> pred-subject (get-in acc k)]
>> (if (or (and optional (nil? pred-subject))
>> (not (empty? (get-in acc error-path)))
>> (apply pred pred-subject args))
>>   acc
>>   (update-in acc error-path
>>  #(conj % (format message (name (peek k
>>
>> Cheers,
>>   ~Gary
>>
>>
>>
>> On Sunday, January 13, 2013 8:03:36 PM UTC-5, Leonardo Borges wrote:
>>
>>> Thanks, really appreciate the kind words.
>>>
>>> I just pushed [bouncer "0.2.2-RC1"] so feel free to give that a go :)
>>>
>>> Cheers,
>>> Leo
>>>
>>> Leonardo Borges
>>> www.leonardoborges.com
>>>
>>>
>>> On Fri, Jan 11, 2013 at 3:44 PM, faenvie  wrote:
>>>

 i took a look at it. bouncers DSL seems smart inside and out.
 Has an excellent Documentation too. Thanks for sharing it.

  --
 You received this message because you are subscribed to the Google
 Groups "Clojure" group.
 To post to this group, send email to clo...@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+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=en

>>>
>>>  --
>> 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
>>
>
>

-- 
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...@googlegroup

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Leonardo Borges
Hi Gary,

Thanks for the bug report.

Which version of Clojure causes the issue? I've been using Clojure 1.4 and
the exact snippet you posted works flawlessly. As well as bouncer, given I
have test cases around validators with no explicit messages.


Cheers,

Leonardo Borges
www.leonardoborges.com


On Tue, Jan 15, 2013 at 7:52 AM, Gary Johnson  wrote:

> Hey Leonardo,
>
>   There's a critical bug in 0.2.2-RC1 in the bouncers.core/wrap function.
> An IllegalArgumentException is triggered whenever a validator is not passed
> an explicit :message field. It looks like this was introduced in the
> process of trying to allow validators to take an arbitrary number of input
> args (a very good thing IMO). Here's a minimum case for replicating this
> error at your repl:
>
> (let [{:keys [message] :or {message "foo"}} '()] message)
> IllegalArgumentException No value supplied for key: null
> clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)
>
> This is being triggered in your wrap function when you apply map
> destructuring to the right-hand result of (split-with (complement keyword?)
> args). Anyway, here is a patched version of wrap that should fix the
> problem. FWIW, I also fixed the docstring typo "erros" -> "errors".
>
> (defn wrap
>   "Wraps pred in the context of validating a single value
>
>   - `acc`  is the map being validated
>
>   - `pred` is a validator
>
>   - `k`the path to the value to be validated in the associative
> structure acc
>
>   - `args` any extra args to pred
>
>   It only runs pred if:
>
>   - the validator is optional *and* there is a non-nil value to be
> validated (this information is read from pred's metadata)
>
>   - there are no previous errors for the given path
>
>   Returns `acc` augmented with a namespace qualified ::errors keyword
> "
>   [acc [pred k & args]]
>   (let [pred (h/resolve-or-same pred)
> k (if (vector? k) k [k])
> error-path (cons ::errors k)
> {:keys [default-message-format optional]} (meta pred)
> [args message-kv] (split-with (complement keyword?) args)
> message (get (apply hash-map message-kv) :message
> default-message-format)
> pred-subject (get-in acc k)]
> (if (or (and optional (nil? pred-subject))
> (not (empty? (get-in acc error-path)))
> (apply pred pred-subject args))
>   acc
>   (update-in acc error-path
>  #(conj % (format message (name (peek k
>
> Cheers,
>   ~Gary
>
>
>
> On Sunday, January 13, 2013 8:03:36 PM UTC-5, Leonardo Borges wrote:
>
>> Thanks, really appreciate the kind words.
>>
>> I just pushed [bouncer "0.2.2-RC1"] so feel free to give that a go :)
>>
>> Cheers,
>> Leo
>>
>> Leonardo Borges
>> www.leonardoborges.com
>>
>>
>> On Fri, Jan 11, 2013 at 3:44 PM, faenvie  wrote:
>>
>>>
>>> i took a look at it. bouncers DSL seems smart inside and out.
>>> Has an excellent Documentation too. Thanks for sharing it.
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@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+u...@**googlegroups.com
>>>
>>> For more options, visit this group at
>>> http://groups.google.com/**group/clojure?hl=en
>>>
>>
>>  --
> 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
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-14 Thread Gary Johnson
Hey Leonardo,

  There's a critical bug in 0.2.2-RC1 in the bouncers.core/wrap function. 
An IllegalArgumentException is triggered whenever a validator is not passed 
an explicit :message field. It looks like this was introduced in the 
process of trying to allow validators to take an arbitrary number of input 
args (a very good thing IMO). Here's a minimum case for replicating this 
error at your repl: 

(let [{:keys [message] :or {message "foo"}} '()] message)
IllegalArgumentException No value supplied for key: null  
clojure.lang.PersistentHashMap.create (PersistentHashMap.java:77)

This is being triggered in your wrap function when you apply map 
destructuring to the right-hand result of (split-with (complement keyword?) 
args). Anyway, here is a patched version of wrap that should fix the 
problem. FWIW, I also fixed the docstring typo "erros" -> "errors".

(defn wrap
  "Wraps pred in the context of validating a single value

  - `acc`  is the map being validated

  - `pred` is a validator

  - `k`the path to the value to be validated in the associative 
structure acc

  - `args` any extra args to pred

  It only runs pred if:

  - the validator is optional *and* there is a non-nil value to be 
validated (this information is read from pred's metadata)

  - there are no previous errors for the given path

  Returns `acc` augmented with a namespace qualified ::errors keyword
"
  [acc [pred k & args]]
  (let [pred (h/resolve-or-same pred)
k (if (vector? k) k [k])
error-path (cons ::errors k)
{:keys [default-message-format optional]} (meta pred)
[args message-kv] (split-with (complement keyword?) args)
message (get (apply hash-map message-kv) :message 
default-message-format)
pred-subject (get-in acc k)]
(if (or (and optional (nil? pred-subject))
(not (empty? (get-in acc error-path)))
(apply pred pred-subject args))
  acc
  (update-in acc error-path
 #(conj % (format message (name (peek k

Cheers,
  ~Gary


On Sunday, January 13, 2013 8:03:36 PM UTC-5, Leonardo Borges wrote:
>
> Thanks, really appreciate the kind words.
>
> I just pushed [bouncer "0.2.2-RC1"] so feel free to give that a go :)
>
> Cheers,
> Leo
>
> Leonardo Borges
> www.leonardoborges.com
>
>
> On Fri, Jan 11, 2013 at 3:44 PM, faenvie  >wrote:
>
>>
>> i took a look at it. bouncers DSL seems smart inside and out. 
>> Has an excellent Documentation too. Thanks for sharing it.
>>
>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@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+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>>
>
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-13 Thread Leonardo Borges
Thanks, really appreciate the kind words.

I just pushed [bouncer "0.2.2-RC1"] so feel free to give that a go :)

Cheers,
Leo

Leonardo Borges
www.leonardoborges.com


On Fri, Jan 11, 2013 at 3:44 PM, faenvie  wrote:

>
> i took a look at it. bouncers DSL seems smart inside and out.
> Has an excellent Documentation too. Thanks for sharing it.
>
>  --
> 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
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-13 Thread Leonardo Borges
I just pushed [bouncer "0.2.2-RC1"] - would appreciate if you could give
that a go.

You can check the changelog to see what's new:
https://github.com/leonardoborges/bouncer/blob/master/CHANGELOG.md#022-unreleased

But the big changes include:

- a qualified keyword for the errors entry and;
- a short-circuit mechanism as suggested by Gary

If everything looks good or I don't hear back, I'll push 0.2.2 final to
clojars tomorrow and send a full ANN post.

Cheers and thanks for the great feedback.

Leo.

Leonardo Borges
www.leonardoborges.com


On Fri, Jan 11, 2013 at 10:35 AM, Leonardo Borges <
leonardoborges...@gmail.com> wrote:

> Hi Gary,
>
> First off, I wanna thank you for you thorough review and feedback of
> bouncer - it's very much appreciated.
>
> Please see my comments inline.
>
>
> On Fri, Jan 11, 2013 at 2:35 AM, Gary Johnson  wrote:
> > Also, I agree with Stathis that there is a problem including the errors
> map
> > in the original data structure under an unqualified keyword. Of course,
> if
> > you change validate to not modify the input map that is being validated,
> > then you no longer need a state monad to model the validation workflow.
> This
> > could just as easily be done with a simple reduce. In this instance, I'd
> > guess that just qualifying the ::errors keyword would probably stick
> closest
> > to your original model. Maybe I'm totally missing the mark here though.
> >
>
> Sold. You're the second person to mention this so I believe it's worth
> considering.
>
> My original thinking was to use the errors key as a convention for
> validation errors but
> given the multitude of domains this could be applied to, that might
> have been a bit too selfish.
>
> I'll add a qualified error keyword to the next release.
>
> >
> > So basically what I'm suggesting as an enhancement to your library is
> that
> > whenever a field is being tested with a multi-validator vector, the first
> > test to fail should prevent any other tests (to its right in the vector)
> > from running. This would be similar in spirit to the behavior of the -?>
> and
> > -?>> thread-maybe macros in clojure.core.incubator.
> >
>
> This makes sense. Thanks for the code snippets - they illustrated your
> point brilliantly.
>
> The current design shifts that onus to the validators and in cases
> such as the one
> demonstrated by your second code snippet, this is far from ideal.
>
> I've put your code in the test suite which means I now have a broken
> build I need to fix :)
>
> This would be a great addition to bouncer. I'll take some time to go
> over a couple of implementation
> options but I'm keen on adding it in.
>
> > Okay, constructive criticism and all that aside, great work on this
> library
> > again. Looking forward to the next release soon.
> >
> >   ~Gary
> >
>
> I'm glad you enjoyed the lib - stay tuned, I'll probably have news
> over the weekend.
>
> Cheers,
> Leo.
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-11 Thread Leonardo Borges
Leonardo Borges
www.leonardoborges.com
On Jan 11, 2013 3:44 PM, "faenvie"  wrote:

>
> i took a look at it. bouncers DSL seems smart inside and out.
> Has an excellent Documentation too. Thanks for sharing it.
>
> --
> 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

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-10 Thread faenvie

i took a look at it. bouncers DSL seems smart inside and out. 
Has an excellent Documentation too. Thanks for sharing it.

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-10 Thread Leonardo Borges
Hi Gary,

First off, I wanna thank you for you thorough review and feedback of
bouncer - it's very much appreciated.

Please see my comments inline.


On Fri, Jan 11, 2013 at 2:35 AM, Gary Johnson  wrote:
> Also, I agree with Stathis that there is a problem including the errors map
> in the original data structure under an unqualified keyword. Of course, if
> you change validate to not modify the input map that is being validated,
> then you no longer need a state monad to model the validation workflow. This
> could just as easily be done with a simple reduce. In this instance, I'd
> guess that just qualifying the ::errors keyword would probably stick closest
> to your original model. Maybe I'm totally missing the mark here though.
>

Sold. You're the second person to mention this so I believe it's worth
considering.

My original thinking was to use the errors key as a convention for
validation errors but
given the multitude of domains this could be applied to, that might
have been a bit too selfish.

I'll add a qualified error keyword to the next release.

>
> So basically what I'm suggesting as an enhancement to your library is that
> whenever a field is being tested with a multi-validator vector, the first
> test to fail should prevent any other tests (to its right in the vector)
> from running. This would be similar in spirit to the behavior of the -?> and
> -?>> thread-maybe macros in clojure.core.incubator.
>

This makes sense. Thanks for the code snippets - they illustrated your
point brilliantly.

The current design shifts that onus to the validators and in cases
such as the one
demonstrated by your second code snippet, this is far from ideal.

I've put your code in the test suite which means I now have a broken
build I need to fix :)

This would be a great addition to bouncer. I'll take some time to go
over a couple of implementation
options but I'm keen on adding it in.

> Okay, constructive criticism and all that aside, great work on this library
> again. Looking forward to the next release soon.
>
>   ~Gary
>

I'm glad you enjoyed the lib - stay tuned, I'll probably have news
over the weekend.

Cheers,
Leo.

-- 
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


Re: ANN: bouncer, validation library for clojure

2013-01-10 Thread Gary Johnson
Thanks for releasing this library. I've written quite a few large 
command-line driven applications in Clojure thus far, and each one has used 
a slightly different homegrown approach as different core functionality 
became available (and the contrib libs kept mutating). Your state monad 
inspired approach definitely clicks with me, and I'll be looking forward to 
your future releases.

Also, I agree with Stathis that there is a problem including the errors map 
in the original data structure under an unqualified keyword. Of course, if 
you change validate to not modify the input map that is being validated, 
then you no longer need a state monad to model the validation workflow. 
This could just as easily be done with a simple reduce. In this instance, 
I'd guess that just qualifying the ::errors keyword would probably stick 
closest to your original model. Maybe I'm totally missing the mark here 
though.

Additionally, one thing that bit me when using validate with multiple tests 
was that there's no early exit strategy. For example, imagine I have 
written a test like the following:

(def config-params {:input-dir "some/directory/path" :output-dir 
"some/other/directory/path"})

(defvalidator directory
  {:default-message-format "%s must be a valid directory" :optional false}
  [path]
  (.isDirectory ^File (clojure.java.io/file path)))

(defvalidator readable
  {:default-message-format "%s is not readable" :optional false}
  [path]
  (.canRead ^File (clojure.java.io/file path)))

(defvalidator writeable
  {:default-message-format "%s is not writeable" :optional false}
  [path]
  (.canRead ^File (clojure.java.io/file path)))

(validate config-params
  :input-dir [required directory readable]
  :output-dir [required directory writeable])

The problem that I run into is that if for some reason :input-dir or 
:output-dir are not defined in config-params, then I get a 
NullPointException when .isDirectory is called in the directory validator. 
I can, of course, dodge this bullet by setting :optional true in the 
directory, readable, and writeable validators. However, as evidenced by the 
required validator's presence in my test vectors, I actually do want these 
fields to be present and to pass all tests. So the semantics sort of look a 
bit off to me in this instance.

Another case that perhaps illustrates my point a little more clearly is 
this one:

(defvalidator <10 {:default-message-format "%s must be less than 10" 
:optional false} [x] (< x 10))

(validate {:foo "I'm a string, but I should be a number"}
  :foo [required number <10])

Here, I obviously get this exception: ClassCastException java.lang.String 
cannot be cast to java.lang.Number  clojure.lang.Numbers.lt

Again, my problem is that since number fails, I would like <10 to never be 
called. The :optional flag can't help me here because it only disables 
validators in the case of a nil input.

So basically what I'm suggesting as an enhancement to your library is that 
whenever a field is being tested with a multi-validator vector, the first 
test to fail should prevent any other tests (to its right in the vector) 
from running. This would be similar in spirit to the behavior of the -?> 
and -?>> thread-maybe macros in clojure.core.incubator.

Okay, constructive criticism and all that aside, great work on this library 
again. Looking forward to the next release soon.

  ~Gary

On Wednesday, January 9, 2013 4:24:14 PM UTC-5, Leonardo Borges wrote:
>
> Stathis, 
>
> That's a very good point. I've been thinking about the usefulness of 
> returning the errors map in the original map since the errors map itself is 
> returned as the first element in the call to 'validate'. 
>
> To be honest I'm tempted to remove that with the next release, making 
> validate return a single value: the errors map. 
>
> I'm happy for you to argue otherwise though. Do you think having the 
> qualified keywords in the original map is still useful? 
>
> I'll be releasing a new version over the weekend that will include this 
> change. 
>
> Thanks for the feedback
>
> Leonardo Borges
> www.leonardoborges.com
> On Jan 10, 2013 7:08 AM, "Stathis Sideris" > 
> wrote:
>
>> Hey Leonardo,
>>
>> This is very interesting, but I'd like to know whether it's possible to 
>> validate a map that contains an :errors key. Would bouncer overwrite this 
>> with its own :errors key? Should it not be using a fully-qualified keyword 
>> (as in ::errors) to avoid the clash?
>>
>> Thanks,
>>
>> Stathis
>>
>>
>> On Friday, 4 January 2013 06:56:19 UTC, Leonardo Borges wrote:
>>>
>>> Hey guys, 
>>>
>>> I extracted a small validation library from a side project I'm working 
>>> on and bouncer is the result. 
>>>
>>> While I do know there are a couple of validation libs out there 
>>> already, I decided this was worth publishing mostly because: 
>>>
>>> - That’s what I’m using in my current side project 
>>> - It takes a fundamentally different implementation approach that is 
>>> in itself worthy o

Re: ANN: bouncer, validation library for clojure

2013-01-09 Thread Leonardo Borges
Stathis,

That's a very good point. I've been thinking about the usefulness of
returning the errors map in the original map since the errors map itself is
returned as the first element in the call to 'validate'.

To be honest I'm tempted to remove that with the next release, making
validate return a single value: the errors map.

I'm happy for you to argue otherwise though. Do you think having the
qualified keywords in the original map is still useful?

I'll be releasing a new version over the weekend that will include this
change.

Thanks for the feedback

Leonardo Borges
www.leonardoborges.com
On Jan 10, 2013 7:08 AM, "Stathis Sideris"  wrote:

> Hey Leonardo,
>
> This is very interesting, but I'd like to know whether it's possible to
> validate a map that contains an :errors key. Would bouncer overwrite this
> with its own :errors key? Should it not be using a fully-qualified keyword
> (as in ::errors) to avoid the clash?
>
> Thanks,
>
> Stathis
>
>
> On Friday, 4 January 2013 06:56:19 UTC, Leonardo Borges wrote:
>>
>> Hey guys,
>>
>> I extracted a small validation library from a side project I'm working
>> on and bouncer is the result.
>>
>> While I do know there are a couple of validation libs out there
>> already, I decided this was worth publishing mostly because:
>>
>> - That’s what I’m using in my current side project
>> - It takes a fundamentally different implementation approach that is
>> in itself worthy of exploration
>> - If nothing else, this is yet another example of where Monads can be
>> useful.
>>
>> The full reasoning can be found in a post I wrote:
>> https://bitly.com/ZiLJzO
>>
>> Where to find it:
>>
>> Github: 
>> https://github.com/**leonardoborges/bouncer
>> Clojars: https://clojars.org/bouncer
>>
>> The README file on github contains a detailed guide to using the
>> library, hopefully that's enough should you want to try it out.
>>
>> Cheers,
>> Leonardo Borges
>> www.leonardoborges.com
>>
>  --
> 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

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-09 Thread Leonardo Borges
The ones I looked at were https://github.com/r0man/validation-clj and
https://github.com/michaelklishin/validateur


Cheers,
Leonardo Borges
www.leonardoborges.com


On Wed, Jan 9, 2013 at 4:29 PM, Karim Nassar  wrote:
> what are the other validation libraries?
>
> TIA,
> Karim
>
> --
> Karim
>
>
> On Thu, Jan 3, 2013 at 10:56 PM, Leonardo Borges
>  wrote:
>>
>> Hey guys,
>>
>> I extracted a small validation library from a side project I'm working
>> on and bouncer is the result.
>>
>> While I do know there are a couple of validation libs out there
>> already, I decided this was worth publishing mostly because:
>>
>> - That’s what I’m using in my current side project
>> - It takes a fundamentally different implementation approach that is
>> in itself worthy of exploration
>> - If nothing else, this is yet another example of where Monads can be
>> useful.
>>
>> The full reasoning can be found in a post I wrote:
>> https://bitly.com/ZiLJzO
>>
>> Where to find it:
>>
>> Github: https://github.com/leonardoborges/bouncer
>> Clojars: https://clojars.org/bouncer
>>
>> The README file on github contains a detailed guide to using the
>> library, hopefully that's enough should you want to try it out.
>>
>> Cheers,
>> Leonardo Borges
>> www.leonardoborges.com
>>
>> --
>> 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
>
>
> --
> 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

-- 
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


Re: ANN: bouncer, validation library for clojure

2013-01-09 Thread Stathis Sideris
Hey Leonardo,

This is very interesting, but I'd like to know whether it's possible to 
validate a map that contains an :errors key. Would bouncer overwrite this 
with its own :errors key? Should it not be using a fully-qualified keyword 
(as in ::errors) to avoid the clash?

Thanks,

Stathis


On Friday, 4 January 2013 06:56:19 UTC, Leonardo Borges wrote:
>
> Hey guys, 
>
> I extracted a small validation library from a side project I'm working 
> on and bouncer is the result. 
>
> While I do know there are a couple of validation libs out there 
> already, I decided this was worth publishing mostly because: 
>
> - That’s what I’m using in my current side project 
> - It takes a fundamentally different implementation approach that is 
> in itself worthy of exploration 
> - If nothing else, this is yet another example of where Monads can be 
> useful. 
>
> The full reasoning can be found in a post I wrote: 
> https://bitly.com/ZiLJzO 
>
> Where to find it: 
>
> Github: https://github.com/leonardoborges/bouncer 
> Clojars: https://clojars.org/bouncer 
>
> The README file on github contains a detailed guide to using the 
> library, hopefully that's enough should you want to try it out. 
>
> Cheers, 
> Leonardo Borges 
> www.leonardoborges.com 
>

-- 
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

Re: ANN: bouncer, validation library for clojure

2013-01-09 Thread Karim Nassar
what are the other validation libraries?

TIA,
Karim

--
Karim


On Thu, Jan 3, 2013 at 10:56 PM, Leonardo Borges <
leonardoborges...@gmail.com> wrote:

> Hey guys,
>
> I extracted a small validation library from a side project I'm working
> on and bouncer is the result.
>
> While I do know there are a couple of validation libs out there
> already, I decided this was worth publishing mostly because:
>
> - That’s what I’m using in my current side project
> - It takes a fundamentally different implementation approach that is
> in itself worthy of exploration
> - If nothing else, this is yet another example of where Monads can be
> useful.
>
> The full reasoning can be found in a post I wrote:
> https://bitly.com/ZiLJzO
>
> Where to find it:
>
> Github: https://github.com/leonardoborges/bouncer
> Clojars: https://clojars.org/bouncer
>
> The README file on github contains a detailed guide to using the
> library, hopefully that's enough should you want to try it out.
>
> Cheers,
> Leonardo Borges
> www.leonardoborges.com
>
> --
> 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
>

-- 
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