This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-18
Channels
- # admin-announcements (3)
- # arachne (8)
- # beginners (55)
- # boot (51)
- # cbus (1)
- # cider (15)
- # cljs-dev (5)
- # cljsrn (8)
- # clojure (203)
- # clojure-austin (2)
- # clojure-belgium (12)
- # clojure-boston (6)
- # clojure-czech (47)
- # clojure-dusseldorf (14)
- # clojure-estonia (1)
- # clojure-greece (42)
- # clojure-japan (2)
- # clojure-poland (4)
- # clojure-russia (97)
- # clojure-sg (5)
- # clojure-uk (41)
- # clojurescript (122)
- # code-reviews (4)
- # component (3)
- # core-matrix (19)
- # cursive (25)
- # datomic (16)
- # devcards (24)
- # editors (6)
- # euroclojure (1)
- # hoplon (88)
- # immutant (3)
- # incanter (4)
- # jobs (5)
- # keechma (1)
- # luminus (1)
- # om (44)
- # onyx (22)
- # parinfer (3)
- # planck (1)
- # proton (3)
- # re-frame (5)
- # reagent (30)
- # ring (2)
- # spacemacs (1)
- # untangled (92)
- # yada (1)
hey, what would be a good way to validate/coerce/enforce constraints on data going into datascript
like, i want some attribute to always be a float, for example
ideally you'd have functions a level higher than transact!
validating the inputs. Otherwise you can have your own transact!
which takes a schema (or is called with an implicit schema) that the validations are run against.
so why would you suggest something higher level than a custom transact!
?
maybe i need a defmulti...
so i have something that looks loosely like this
(defc foo "")
(input
:value foo
:input (if-let [n (parse-number @%)] (reset! foo n)))
i’m trying to stop values i don’t like
but if someone writes 42a
foo
is not reset, so :value
does not update
you don’t even know what i’m doing...
only numbers are OK for this input
well i want to accept numbers in the field but not letters
if i get it working, i’ll add errors and stuff to make it obvious what is going on
starting with the basics
no, it doesn’t work that way
:value
only does something if the cell changes
kind of irrelevant
do you actually want to show whatever user inputs, but only store the valid input in the cell?
either is fine
i only want to store valid input
but if you don’t store it, it will just disappear on page refresh
it will silently die
hangong, i’m going to restart slack
it’s freaking
like..
(defc foo "")
(defc foo-raw "")
(input
:value foo
:data-error (cell= (= foo foo-raw)
:input (do (if-let [n (parse-number @%)] (reset! foo n))
(reset! foo-raw @%)))
well.. no
i mean, it doesn’t matter
it’s beside the point
because the user can write whatever they want in the field and :value
gets stale the moment something doesn’t validate
it’s either not representing what is actually being used for calculations elsewhere, because it’s not showing the valid bit
or it is showing what will be used for calculations when you load up the page, but you might lose some (invalid) input
it’s like...
i’m using cells to make the app more responsive, no need to submit forms and wait for a page refresh
but now i’m not sure what to do, show calculations that don’t line up with input, or restrict input, or… something else??
but it’s just not possible
which means showing whatever user typed in, highlighting errors and running calculations only when the error is cleared
spreadsheets don’t do that (for example)
ok so um
that’s a good question
actually
i think i need to sleep on this
:value
is giving me so much grief, lol
@jumblerg: wow, i was extending the clj castra writer to convert joda-time to instant just last week!
@onetom: good to know i’m not the only one. you can use it as follows:
(defn remote [endpoint & [opts]]
(let [opts* {:url url :on-error #(when dev (println %)) :reader-opts {:handlers {"r" identity}}}]
(c/mkremote endpoint q/session q/error q/loading (merge opts* opts))))
@jumblerg: thx that’s just the ext file. i grabbed the jar from clojars. I just needed to look at the source
yeah, there’s a hoplon defelem that @alandipert or @micha whipped up a while back
@raywillig: you can view the files in the jar with vi or emacs, i think both know how to do that out of the box
in emacs at least you can edit jars in place also, which is handy/dangerous
but i do it on the reg