How to validate date in malli schema? What is the data type that I must use?
I checked with local-date, but its not valid in clojure. This is the code I followed.
(def date (m/schema [:map
[:a :int]
[:b :re #"\d{4}-\d{2}-\d{2}"]
]))
Thsi worked fine when I validated.
(m/validate s2 {:a 1 :b "2022-07-28"})
=> true
But when I try to convert this to Json schema, I get error as such.
(def s2 [:map
[:orderId string?]
[:OrderDate :re "\d{4}-\d{2}-\d{2}"]
])
Syntax error reading source at (REPL:3:24).
Unsupported escape character: \d
So how must in resolve this? Edit : Reslved. Use it as
:re #"\d{4}-\d{2}-\d{2}" OR [:re "\d{4}-\d{2}-\d{2}"]
But now validation fails :
(m/validate s2 {:a 1 :b "2022-07-28"})
=> false