This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-03-04
Channels
- # adventofcode (6)
- # announcements (1)
- # aws (18)
- # beginners (104)
- # boot (11)
- # cljsrn (31)
- # clojure (49)
- # clojure-dev (16)
- # clojure-europe (2)
- # clojure-greece (9)
- # clojure-houston (1)
- # clojure-italy (12)
- # clojure-nl (3)
- # clojure-spec (46)
- # clojure-uk (148)
- # clojurescript (12)
- # community-development (13)
- # core-async (7)
- # cursive (35)
- # data-science (13)
- # datomic (70)
- # events (1)
- # fulcro (22)
- # hyperfiddle (1)
- # jobs-discuss (10)
- # kaocha (3)
- # off-topic (7)
- # om (2)
- # other-languages (32)
- # parinfer (1)
- # portkey (4)
- # re-frame (3)
- # reitit (12)
- # shadow-cljs (49)
- # spacemacs (1)
- # specter (6)
- # sql (5)
- # tools-deps (58)
any suggestions on the best way to handle multiple validators (with corresponding error message) with form state?
so even with spec if i have (s/and nonblank? less-than-10-chars?), i’d like to be able to distinguish the cases
what’s in the book is what you’ve got. If you want custom rendering based on the cases, you’ll have to write that part into the error message UI code. Form-state doesn’t do the UI parts at all
@eoliphant to distinguish failures with spec, you can use explain-data and then check the :pred field to tell you which predicate failed. It’s not too difficult to setup generic handling for this by using a multi method to dispatch on the predicate and return an error message. I think the “expound” library may do this for you, although I’ve never used it (had to do this on a previous project and it was easy enough to just roll my own solution)
yeah I’ve played around with expound a bit, and there’s another one called ‘parse’ or something that allows you to be explicit with your messages, which is better for user facing stuff, but the last time I checked, the 1.10 improvments had broken some of it.
sorry it was ‘phrase’ not parse https://github.com/alexanderkiel/phrase
@eoliphant as I recall, the main issue was that when spec reported the predicate that caused the failure, for built in predicates it was inconsistent- most of the time it reported the fully qualified name, but sometimes it had just the name, with no namespace. I’m not sure if that changed in 1.10 or not, but can see how fixing it would break the dispatching. That was one reason I didn’t use a library- it’s a quick change to make in my code if spec changes, vs waiting for a library to be updated.
Also, thanks for the pointer to ‘phrase’. I hadn’t seen that library before - might be useful for something I’m working on.
I want to add some extra metadata to a class for something i’m working on.
{:query ..
:my/stuff {..}
is there an api or something that would allow me to get at that info, particularly dynamically? e.g. this -> MyComponent -> :my/stuff
@eoliphant you use the :protocols
key if you’re using defsc
http://book.fulcrologic.com/#_additional_protocol_support
@eoliphant also if it’s a protocol you’re going to be adding a lot, then you can get shorter syntax too, using this https://github.com/fulcrologic/fulcro-incubator/blob/develop/src/main/fulcro/incubator/defsc_extensions.clj#L114
in the incubator
here’s an example of it being used for routing targets