On Monday, October 31, 2016 at 10:41:36 AM UTC-5, Yannick Scherer wrote: > > imho, you're asking spec to do more than it should here - it's not a magic >> wand to wave at all validation problems. >> > > That's good to know. Note that, in regard to the problem stated above, > clojure.spec does not fail its validation responsibilities > – it can perfectly tell me that my data has semantic inconsistencies. > Rather, it's failing at providing means to increase the > usefulness/granularity of any validation errors it emits. >
I disagree with this - you can define specs in a way that is very granular and gives fine-grained errors. The problem where it is falling down for you is the notion of some generic spec + later (dynamic) refinement. We have no intention of adding anything like that beyond what is already provided (things like s/and). > you're asking spec to do more than it should here > > > Can you elaborate? Where do, in this case, the responsibilities of > clojure.spec end? > You are seeking to refine specs dynamically based on runtime state, then validate additional data in terms of those (stateful) specs. I don't think using runtime data is wrong (and I've seen some interesting uses of it). But the use of specs with dynamic variables in particular seems questionable - you've created a stateful spec whose meaning changes over time. To me, this seems like a bad idea (for all the same reasons stateful mutable objects introduce problems). Instead, I think it is far preferable to dynamically generate static specs (which might incorporate parts of existing static specs for the purposes of refinement), than to statically define dynamic specs. It is also important to think about the lifecycle of dynamically generated specs. > > Should clojure.spec only be used for structural validation (with >> [semantic] validation being done explicitly in a second pass) or if >> validation errors with low granularity are okay? > > I think the distinction of structural vs semantic is hazy at best (and more likely not even meaningful) in a predicative dynamic system. I will stick with my narrower advice above that the use of specs with dynamic vars seems like a bad idea to me. -- 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/d/optout.