I am new to Clojure and Clojurescript and here is my Problem. In my webpage I have an input form where the input is string. For further computation with these inputs the input should be integer without a leading zero. So for example "09" is not allowed.
The solution in JavaScript would be:
parseInt("09", 10) // 9
But right now, I am struggling to convert that in my Clojurescript-Code. In my Clojurescript code I already use the parseInt-Function of JavaScript. This works all fine, but I don't know how to add the parameter radix to this specific code:
(defn order
[round-data]
(let [form-data (atom {:round/order 0})
input-data (inputs/make-validated-input
{:class-name "order-input"
:spec :round/order
:placeholder "Bestellung"
:transform js/parseInt
:on-change #(swap! form-data assoc :round/order (.-value %2))
:value-fn #(:round/order @form-data)
:invalid-msg "Bitte eine ganze Zahl eingeben."})
submit-fn (atom #(rf/dispatch [:game/round-commit @form-data]))]
At the :transform key I tried a lot of things like
:transform #(js/parseInt (.-value %2) 10).
Can anybody please help me?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…