This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-01-12
Channels
- # announcements (6)
- # babashka (45)
- # beginners (4)
- # calva (19)
- # cider (2)
- # clj-kondo (10)
- # clj-yaml (10)
- # clojure (25)
- # clojure-boston (1)
- # clojure-conj (3)
- # clojure-europe (34)
- # clojure-losangeles (5)
- # clojure-nl (1)
- # clojure-norway (11)
- # clojure-uk (2)
- # clojurescript (84)
- # cursive (10)
- # datalevin (3)
- # figwheel-main (1)
- # fulcro (1)
- # jobs (5)
- # joyride (25)
- # lsp (17)
- # malli (18)
- # nbb (1)
- # off-topic (1)
- # re-frame (22)
- # remote-jobs (9)
- # scittle (3)
- # shadow-cljs (26)
- # sql (16)
- # tools-build (12)
- # xtdb (44)
How are people handling easy form validation in re-frame?
There are a few libraries that are or should be compatible with re-frame, like: • https://github.com/luciodale/fork • https://github.com/kwladyka/form-validator-cljs • https://github.com/keechma/forms • https://github.com/emil0r/ez-wire Or you can write something on your own - it's easy enough for me to have never needed a library for it.
I am actually using rum and was curious if these would give ideas. But things like Keechma forms don't seem non-trivial, even if they do to you. I didn't realize handling forms like this would take 600+ lines of clojure
I'm surprised there's not a solution involving generating forms from Malli
I myself end up writing custom stuff in my projects because I either have very simple forms that would only suffer from a library or I have forms so complicated that using a library with its own idiosyncrasies would make them even more complicated (interdependent field values, visibility, validation, dynamic forms).
So let's assume I wanted all of those things you listed. How would you handle that type of thing?
Particularly displaying validation errors and interdependent field values
> How would you handle that type of thing? Ad-hoc. I haven't been able to come up with a proper grammar for something like this. Don't know if a grammar that's better than an ad-hoc imperative solution is feasible at all, but if it is, I doubt it would be worth it for my own projects, where I have one project with such forms per 5+ years (although, I've been told one shouldn't consider a single point of data to be of any statistical significance. :D)
That's unfortunate. I'm getting convinced nobody has ever done a scalable version of like this in CLJS with how people have been responding
React-hook-forms
Django models automatically creating forms
And how do they handle dynamic forms with interdependent field values, visibility, and validation?
I've worked with Django extensively, although years ago. It offers no such thing. Some primitive stuff like generating a set of fields and trivial validations based on whatever you put in the model - sure. Anything more complex than that, and Django just gets in the way.
That's true, Django doesn't solve those parts. But creating a form is insanely easy. There are loads of form libraries in React for this sort of thing
Easy isn't always good. Django is easy but far from simple. And in the other thread, you have been given a suggestion to use a library that works just like you describe, and the only problem, as it seems to me, is that it works with spec but not Malli.
It doesn't actually work like I described
What does it not do that you need? Please respond in that other thread though - no need to keep it here.
What was your experience with that? Was it worth it or do you feel writing your own validation functions would've been easier?