Fork me on GitHub
#re-frame
<
2015-08-23
>
simax9913:08:05

I'm trying (unsuccessfully) to use a regex with the re-com input-text component. I've taken the regex expression from the re-com demo page for the input-text component but can't seem to get it to work. When I try and type anything into the textbox, nothing appears. If I remove the :validation-regex key and type into the textbox, the characters appear as expected. What am I doing wrong? The code

(defn main-component []

  (let [data (reagent/atom "")
        regex (reagent/atom #"^(\\d{0,2})$|^(\\d{0,2}\\.\\d{0,1})$")]
    (fn
      []
      [v-box
       :size "auto"
       :gap "10px"
       :children
       [
        [box :width "150px" :child [label :label "Enter data..."]]
        [box :child [input-text
                     :width "300px"
                     :model data
                     :on-change #(reset! data %)
                     :validation-regex @regex
                     :change-on-blur? false]]
        ]])))

sisawat14:08:44

Is there a free for commercial use db that is commonly used with re-frame instead of datomic?

simax9914:08:17

Looks as though the regex I needed was #"^(-{0,1})(\d{0,2})$". I want the textbox to only accept integers in the range (-99 to +99)

ulsa18:08:40

A funny rookie mistake is apparently to forget the hash on an anonymous on-click callback fn. Events started flowing like crazy whenever mouse was moved.

gregg20:08:08

@simax99: regex's catch us all! My favourite place to test these is: https://regex101.com/?#javascript

gregg20:08:27

Also, there are a few more samples for inspiration here: https://github.com/Day8/re-com/blob/master/src/re_com/misc.cljs#L34-L39

danielcompton21:08:58

@sisawat: re-frame is agnostic of backend database, AFAIK there isn’t any special integration with datomic

sisawat21:08:09

I know, I think I was more asking what the clojure stacks of choice where

simax9921:08:19

@gregg thanks for the links