On 9 April 2011 10:07, Ken Wesson <kwess...@gmail.com> wrote: >> That particular example ties a predicate to a particular error >> message. Error messages should be independent of predicates, otherwise >> they can't be localized or changed to fit a specific situation. > > It can always be an integer or a keyword (or a string!) used to look > up the localized or situation-specific message in a map.
It's still not as flexible, because different keywords with the same validation may require different error messages. It could perhaps work with a Turing-complete localization system, i.e. one where localizations are performed by arbitrary scripts, but I don't think a validation system should depend on having a sophisticated localization system. I also don't like the idea of tying together two pieces of functionality that could conceivably be separated. I prefer simple functions over compound ones. >> This would lead to a lot of validations with "not" in front of them. >> i.e not-email-address?, not-integer?, etc. > > So? It's redundant, doesn't read as well, and reverses people's usual conceptions about validations. I'd prefer treating validations as a contract, i.e. defining what user data must do to pass, rather than what it must do to fail. - James -- 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