Fixes to the phone tag
This commit is contained in:
parent
8598463ec7
commit
50d50aab94
|
@ -1,5 +1,6 @@
|
||||||
(ns adl-support.core
|
(ns adl-support.core
|
||||||
(:require [clojure.core.memoize :as memo]
|
(:require [clojure.core.memoize :as memo]
|
||||||
|
[clojure.data.json :as json]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.string :refer [split join]]
|
[clojure.string :refer [split join]]
|
||||||
[clojure.tools.logging]))
|
[clojure.tools.logging]))
|
||||||
|
@ -36,12 +37,15 @@
|
||||||
vr (if
|
vr (if
|
||||||
(string? v)
|
(string? v)
|
||||||
(try
|
(try
|
||||||
(read-string v)
|
(json/read-str v)
|
||||||
(catch Exception _ nil)))]
|
(catch Exception _ nil)))]
|
||||||
(cond
|
(cond
|
||||||
(nil? v) {}
|
(nil? v) {}
|
||||||
(= v "") {}
|
(= v "") {}
|
||||||
(number? vr) {(keyword k) vr}
|
(and
|
||||||
|
(number? vr)
|
||||||
|
;; there's a problem that json/read-str will read "07777 888999" as 7777
|
||||||
|
(re-matches #"^[0-9.]+$" v)) {(keyword k) vr}
|
||||||
true
|
true
|
||||||
{(keyword k) v})))
|
{(keyword k) v})))
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
(def *default-international-dialing-prefix*
|
(def ^:dynamic *default-international-dialing-prefix*
|
||||||
"The international dialing prefix to use, if none is specified."
|
"The international dialing prefix to use, if none is specified."
|
||||||
"44")
|
"44")
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,10 @@
|
||||||
(let [expected {:id 67 :offset 0 :limit 50}
|
(let [expected {:id 67 :offset 0 :limit 50}
|
||||||
actual (massage-params {:params {:id "0" :offset "1000" :limit "150"}
|
actual (massage-params {:params {:id "0" :offset "1000" :limit "150"}
|
||||||
:form-params {:id "67" :offset "0" :limit "50"}})]
|
:form-params {:id "67" :offset "0" :limit "50"}})]
|
||||||
(is (= expected actual) "Request with form params, params and form params differ"))))
|
(is (= expected actual) "Request with form params, params and form params differ"))
|
||||||
|
(let [expected {:phone "07777 888999"}
|
||||||
|
actual (massage-params {:params {:phone "07777 888999"}})]
|
||||||
|
(is (= expected actual) "A phone number with a space in needs to be treated as a string"))))
|
||||||
|
|
||||||
|
|
||||||
(deftest compose-exception-reason-tests
|
(deftest compose-exception-reason-tests
|
||||||
|
|
Loading…
Reference in a new issue