This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-07-10
Channels
- # announcements (1)
- # babashka (17)
- # biff (7)
- # calva (6)
- # clerk (5)
- # clj-on-windows (1)
- # clojure (59)
- # clojure-austin (17)
- # clojure-brasil (1)
- # clojure-europe (40)
- # clojure-nl (2)
- # clojure-norway (103)
- # clojure-sweden (9)
- # clojure-uk (8)
- # clojurescript (8)
- # cursive (25)
- # data-science (5)
- # datalevin (7)
- # datomic (4)
- # emacs (8)
- # etaoin (13)
- # hyperfiddle (26)
- # lsp (8)
- # malli (7)
- # off-topic (9)
- # polylith (13)
- # releases (2)
- # sql (7)
is it a bad idea to try to do "check that no user with this email already exists" type of validation with malli? If not, I'd appreciate any pointers on how to pass my datasource
to the validation fn. Seems like the validators take options but I haven't been able to figure out exactly what those options can be used for just yet
Similar questions have come up in this channel a few times. I think it's not a good idea. I would recommend restricting Malli to verify that the data is of the right "shape", not that you haven't seen that email before. (Nor that it's valid, for that matter, since only really attempting to send a validation email can do that.) That said, if you have an entity with multiple email addresses in it, you can certainly check that all those are distinct from eachother with Malli.
Performance cost is one reason, and difficulty of testing. https://clojurians.slack.com/archives/CLDK6MFMK/p1706115115762729?thread_ts=1706111434.068599&cid=CLDK6MFMK There's also another thread here that you might find interesting: https://clojurians.slack.com/archives/CLDK6MFMK/p1691330835332889
Doing side effects in the validation predicate sound like folly. I wouldn't do anything that needs that in it.