Why not just use functions for the validations? string? instead of :String.
Then you get disjunction for free.


On Sat, Jul 27, 2013 at 12:22 PM, ronen <nark...@gmail.com> wrote:

>
> Thanks for the feedback!
>
> Hi,
>>
>> Some feedback and questions, as I've made something similar in the past.
>> - allow normal fns and classes as a predicates.
>>
> - having one global Var for predicates is an antipattern
>>
>
> The Var is only for the built in ones and is internal and private,
> external ones are stored in an atom, if you have better alternative id be
> happy to hear.
>
>
>> - can you compose predicates logically (AND/OR)?
>>
>
> If you mean something along the lines of {:foo #{(or :String :Integer)}}
> then no, in that case I would suggest defining a new validation and use
> that:
>
> (validation :int-or-str (when-not-nil #(or (string? %) (number? %)))
>
> The predicates have implicit AND relation by default.
>
>
>> - can you validate a contents of the vector?
>>
>
> You can write a predicate that goes through a vector and asserts its
> values, there no special support for asserting special positions, do you
> have an example?
>
> As an inspiration, the validator I'm using allows for following rules,
>> which IMHO looks a bit cleaner:
>>
>>
> Your using classes which is indeed useful for the basic types, however it
> complects description with implementation which is what I wanted to avoid,
>
> Nothing for example stops me from taking the description that I use and
> move it to clojurescript (which java classes prevents)
>
> Hope it makes sense
>
>
>> (defn- uri?
>>   "Checks if input is valid URI."
>>   [uri]
>>   (try
>>     (URI. uri)
>>     true
>>     (catch Exception e false)))
>>
>> (def location-rule {:name String :lat Number :long Number})
>>
>> (def contributor-rule {(required :id) uri? :gender #{"m" "f"}
>> :birthDate String
>>                        :locales [String] :homeAddress location-rule})
>>
>> Best,
>> Jozef
>>
>>
>> On Saturday, July 27, 2013 5:50:14 AM UTC+2, ronen wrote:
>>>
>>> Substantiation is an opinionated simple nested map validation library:
>>>
>>>    - Predicates and description kept separate.
>>>    - Validation description map follows validated input structure.
>>>    - Pure data structures to describe validations.
>>>    - Composability of validations is trivial.
>>>    - Validation predicates scope is limited (can only access the
>>>    checked value).
>>>    - High level decisions such as when to activate a group of
>>>    validations should happen on upper layer.
>>>    - Non strict, only described items checked.
>>>
>>> Github: 
>>> https://github.com/narkisr/**substantiation<https://github.com/narkisr/substantiation>
>>>
>>> Feedback is welcome
>>> Ronen
>>>
>>  --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to