Fork me on GitHub
#malli
<
2022-03-19
>
vinurs02:03:30

hello, i define a date schema, validate it is false, what the correct format is ?

(def birthday
  [:fn {:error/message "wrong birthday format" :description "birthday"}
   (partial instance? java.time.LocalDate)])
(m/validate birthday "1987-09-06") => false

Ben Sless08:03:13

You need to add a decoder and decode before validation

ikitommi18:03:38

((partial instance? java.time.LocalDate) "1987-09-06")
; => false

esp119:03:45

Quick question: what is the purpose of having equivalent predicate and type schemas, e.g. int? and :int? Is it simply for convenience? Also, i'm noticing that when I validate using :vector I get an error, while when I use vector? it works:

(m/validate :vector [1 2 3])
; Execution error (ExceptionInfo) at malli.core/-fail! (core.cljc:136).
; :malli.core/child-error {:type :vector, :properties nil, :children nil, :min 1, :max 1}
(m/validate vector? [1 2 3])
true

esp119:03:39

this is with malli 0.8.4

ikitommi18:03:33

> Is it simply for convenience? yes, for people coming from spec. the predicates will be made optional in the future,

ikitommi18:03:31

currently, the :vector expects one child. “vector of anything” would be [:vector :any]

steveb8n01:03:02

Also useful if persisting specs to a db which is sometimes useful

esp100:03:08

cool, thanks for the explanation!