Following along with the example here: https://github.com/metosin/malli#custom-registry
(def registry
(merge
(m/class-schemas)
(m/comparator-schemas)
(m/base-schemas)
{:int (m/fn-schema :int int?)
:bool (m/fn-schema :bool boolean?)}))
(m/validate [:or :int :bool] 'kikka {:registry registry})
; => false
(m/validate [:or :int :bool] 123 {:registry registry})
; => true
It looks like m/fn-schema
no longer exists. I tried using m/-fn-schema
(which does exist) but that didn’t work.
How does this example work with the current code?fixed the README
@jhacks oh, the README is out of sync. This should work:
(m/-simple-schema {:type :boolean, :pred boolean?})
there seems to be (m/-predicate-schema :boolean boolean?)
too
@ikitommi Thanks, both methods work! Is there a way to register a default error message for schemas in the custom registry? For example, the custom :boolean
schema has "unknown error"
for the error message. Could I define a different message?