Fork me on GitHub
#re-frame
<
2023-01-12
>
Dallas Surewood01:01:21

How are people handling easy form validation in re-frame?

p-himik05:01:15

There are a few libraries that are or should be compatible with re-frame, like: • https://github.com/luciodale/forkhttps://github.com/kwladyka/form-validator-cljshttps://github.com/keechma/formshttps://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.

❤️ 2
👍 6
👑 2
Dallas Surewood08:01:41

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

Dallas Surewood08:01:15

I'm surprised there's not a solution involving generating forms from Malli

p-himik08:01:36

Perhaps a niche waiting to be filled? ;)

p-himik08:01:22

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).

Dallas Surewood08:01:00

So let's assume I wanted all of those things you listed. How would you handle that type of thing?

Dallas Surewood08:01:10

Particularly displaying validation errors and interdependent field values

p-himik08:01:48

> 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)

Dallas Surewood08:01:32

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

p-himik08:01:10

Has anyone done something like this in any language/ecosystem?

Dallas Surewood09:01:19

React-hook-forms

Dallas Surewood09:01:30

Django models automatically creating forms

p-himik09:01:19

And how do they handle dynamic forms with interdependent field values, visibility, and validation?

p-himik09:01:18

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.

Dallas Surewood09:01:26

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

p-himik09:01:34

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.

Dallas Surewood09:01:56

It doesn't actually work like I described

p-himik09:01:48

What does it not do that you need? Please respond in that other thread though - no need to keep it here.

hadils20:01:05

I’ve actually implemented a forms validation system for React Native using Malli.

Dallas Surewood20:01:56

What was your experience with that? Was it worth it or do you feel writing your own validation functions would've been easier?

hadils20:01:41

It was worth it. I have declarative forms now.