This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-24
Channels
- # announcements (1)
- # aws (140)
- # beginners (41)
- # calva (47)
- # cider (43)
- # clj-kondo (36)
- # clojure (178)
- # clojure-europe (12)
- # clojure-gamedev (2)
- # clojure-italy (1)
- # clojure-nl (17)
- # clojure-russia (3)
- # clojure-spec (37)
- # clojure-uk (97)
- # clojurescript (173)
- # core-async (16)
- # cursive (18)
- # data-science (2)
- # datascript (6)
- # datomic (32)
- # dirac (16)
- # duct (16)
- # events (2)
- # figwheel-main (7)
- # fulcro (8)
- # graalvm (18)
- # immutant (3)
- # joker (2)
- # kaocha (8)
- # nrepl (6)
- # nyc (2)
- # off-topic (62)
- # quil (3)
- # re-frame (18)
- # reitit (6)
- # ring-swagger (1)
- # shadow-cljs (119)
- # spacemacs (4)
- # specter (2)
- # tools-deps (10)
- # vim (58)
- # xtdb (9)
Hi everyone! I was looking for a good form validation mechanism for JavaScript/React, and thought the something in clojure would be the best inspiration. I found this: https://adambard.com/blog/acceptable-error-handling-in-clojure/ which is close to what I thought out on paper. Is this a good strategy?
@jysh You can try my library https://github.com/kwladyka/form-validator-cljs using spec
and fn
I will update tutorial with better demo how to use it in this week.
Looks interesting! Thank you. I will try to adapt the principles into javascript.
It really works like it should and this interactive things are included in library. At the same time UI is 100% cusomizable. I will update demo to show it better soon.
You define spec
for form and then use spec names for messages:
(ns form-validator-doc.spec
(:require [cljs.spec.alpha :as s]
[clojure.test.check.generators]))
(s/def ::checked boolean)
(s/def ::selected not-empty)
(s/def ::email (s/and string? (partial re-matches #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")))
(s/def ::password-not-empty not-empty)
(s/def ::password-length #(<= 6 (count %)))
(s/def ::password (s/and string? ::password-not-empty ::password-length))
(s/def ::checkbox-with-value (s/and ::checked))
(s/def ::checkbox-without-value (s/and ::checked))
(s/def ::select-one (s/and ::selected #{"green"}))
(s/def ::select-multiple (partial some #{"cat"}))
(s/def ::radio #{"red"})
(s/def ::form (s/keys :req-un [::email ::password
::checkbox-with-value ::checkbox-without-value
::select-one ::select-multiple
::radio]
:opt-un [::password-repeat]))
{::sc/email "Typo? It doesn't look valid."
::sc/password-length "Password has to be minimum 6 characters."
::sc/password-not-empty "Password can't be empty."
::sc/password-special-character "Need to have minimum one special character !@#$%^&*"
:password-not-equal "Password has to be the same."
::sc/selected "You have to choose."
::sc/select-one "Accept only green."
::sc/select-multiple "Cat is obligatory."
::sc/radio "You have to choose red pill."}
for validation like password repeat (compare with another fields) use fn
instead of spec
. It is implementet also.
(defn ?password-repeat [form name]
"Example of validator using multiple inputs values.
form - atom returned by form-init
name - name of the input which call event"
(let [password (get-in @form [:names->value :password])
password-repeat (get-in @form [:names->value name])]
(when-not (= password password-repeat)
[:password-repeat :password-not-equal])))
i've been looking for an example plugin for intellij idea written in clojure, but found none. is it even possible?
There is a #cursive channel if you want to ask there.
@akond it's old, but the following has some clojure bits: https://github.com/JetBrains/la-clojure -- may be it's worth a look?
yes, thank you. i've seen it. i though it would not work because it is outdated. but i will give it a go.
Any emacs users on windows? My organization's policy means I'm locked to windows at work, and emacs just runs so poorly
- installed through scoop
- by 'poorly', I mean everything from daemon startup times, decreasing performance over time, helm minibuffers hanging for seconds before anything happens
- I use spacemacs as a matter of course, but even vanilla emacs is unbearably slow in all these areas
@accounts259 don't know about Emacs on Windows, but if you're looking for an alternative: VSCode + Calva works pretty well for Clojure I've heard
ah yeah, I've got a colleague who runs Emacs with tramp on Windows, don't know the details
I have to admit I've had no problems with emacs performance on Windows when I've used it
shoutout to the person who uploaded the emoji/icon to slack. I've now used this icon as the icon for the VSCode package:
https://marketplace.visualstudio.com/items?itemName=borkdude.clj-kondo
Yeah. Maybe it would be good to save the SVG somewhere, in case there need to be square stickers some day 😉
The svg got lost in the shuffle during a clean install of Catalina. I'll recreate the svg and create a PR.
I guess the file can go into the logo dir. icon.svg + icon.png (128x128) if that's possible?
PR submitted, I think the new version is a tad more accurate. (inc inkscape-skill-level)
it’s cool indeed and fitting but my subconcious need to fix linter errors gives me anxiety just by having this logo on my screen 😬
https://octolinker.now.sh/ looks cool. doesn't support Clojure (yet). maybe a fun project for someone to add. https://github.com/OctoLinker/OctoLinker/issues/288
Hi @seancorfield i just wonder why there is no #4clojure channel here. it could help people who are stucked at some problems and be useful to share solutions.
would #beginners be appropriate?
might get a wider audience though
Feel free to create #4clojure but I think #beginners is probably a better choice since not only will opted-in Clojurians be around to help, other beginners might learn from those discussions.
The java support for OctoLinker is pretty weak, e.g. doesn't work on https://github.com/TheAlgorithms/Java/blob/master/Conversions/BinaryToOctal.java so beyond what I have the time to contribute
works for me - did you add a github token to the extension?
@alexmiller just to check, what works?
It makes a link