Public API for typed ops in malli.core
.
In general these operations:
See also:
Public API for typed ops in `malli.core`. In general these operations: - are macros instead of functions - take Typed Clojure types instead of malli schemas - helps the type checker infer their results See also: - typed.clj.malli.generator - typed.clj.malli.swagger - typed.clj.malli.json-schema
(-instrument tmap & args)
(=> name t)
(defparser name t)
Def parser for Typed Clojure type t. Type checker infers the type of the return value when used.
eg., (defparser AnyInteger-parser t/AnyInteger) (AnyInteger-parser 1) ;=> 1 (AnyInteger-parser nil) ;=> :malli.core/invalid
Def parser for Typed Clojure type t. Type checker infers the type of the return value when used. eg., (defparser AnyInteger-parser t/AnyInteger) (AnyInteger-parser 1) ;=> 1 (AnyInteger-parser nil) ;=> :malli.core/invalid
(defunparser name t)
(defvalidator name t)
Def validator called name for type t. Type checker infers as a predicate on t.
eg., (defvalidator AnyInteger? t/AnyInteger) (AnyInteger? 1) => true (AnyInteger? nil) => false
Def validator called name for type t. Type checker infers as a predicate on t. eg., (defvalidator AnyInteger? t/AnyInteger) (AnyInteger? 1) => true (AnyInteger? nil) => false
(explain t v)
Explain validation failure of v conforming to type t. Type checker infers as a predicate on "not t".
(explain t/AnyInteger 1) => nil (explain t/AnyInteger nil) => {:schema :int, :value nil, :errors ({:path [], :in [], :schema :int, :value nil, :type nil, :message nil})}
Explain validation failure of v conforming to type t. Type checker infers as a predicate on "not t". (explain t/AnyInteger 1) => nil (explain t/AnyInteger nil) => {:schema :int, :value nil, :errors ({:path [], :in [], :schema :int, :value nil, :type nil, :message nil})}
(parse t v)
Parse value v as type t. Type checker infers the shape of return value.
eg., (parse t/AnyInteger 1) ;=> 1 (parse t/AnyInteger nil) ;=> :malli.core/invalid (parse (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool) 1) ;=> [:int 1] (parse (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool) true) ;=> [:bool true]
Parse value v as type t. Type checker infers the shape of return value. eg., (parse t/AnyInteger 1) ;=> 1 (parse t/AnyInteger nil) ;=> :malli.core/invalid (parse (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool) 1) ;=> [:int 1] (parse (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool) true) ;=> [:bool true]
(parser t)
Create parser for Typed Clojure type t. Type checker infers the type of the return value when used.
eg., ((parser t/AnyInteger) 1) ;=> 1 ((parser t/AnyInteger) nil) ;=> :malli.core/invalid ((parser (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool)) 1) ;=> [:int 1] ((parser (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool)) true) ;=> [:bool true]
Create parser for Typed Clojure type t. Type checker infers the type of the return value when used. eg., ((parser t/AnyInteger) 1) ;=> 1 ((parser t/AnyInteger) nil) ;=> :malli.core/invalid ((parser (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool)) 1) ;=> [:int 1] ((parser (t/U ^{::name :int} t/AnyInteger ^{::name :bool} t/Bool)) true) ;=> [:bool true]
(unparse t v)
(unparser t)
(validate t v)
Validate v as type t. Type checker infers as a predicate on t.
eg., (validate t/AnyInteger 1) => true (validate t/AnyInteger nil) => false
Validate v as type t. Type checker infers as a predicate on t. eg., (validate t/AnyInteger 1) => true (validate t/AnyInteger nil) => false
(validator t)
Create validator for type t. Type checker infers as a predicate on t.
eg., ((validator t/AnyInteger) 1) => true ((validator t/AnyInteger) nil) => false
Create validator for type t. Type checker infers as a predicate on t. eg., ((validator t/AnyInteger) 1) => true ((validator t/AnyInteger) nil) => false
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close