Fork me on GitHub
#malli
<
2022-02-08
>
Mutasem Hidmi11:02:18

How can set field to be not required in malli Coercion

dvingo13:02:57

does {:optional true} not work?

pinkfrog14:02:46

I am seeing this coercion failure, but dunno why it fails. It claims missing key, however the key is there.

pinkfrog14:02:51

{
  "schema": "[:map {:closed true} [:email [:re #\"^.+@.+\\..+\"]] [:password [:string {:min 8, :max 30}]]]",
  "errors": [
    {
      "path": [
        "email"
      ],
      "in": [
        "email"
      ],
      "schema": "[:map {:closed true} [:email [:re #\"^.+@.+\\..+\"]] [:password [:string {:min 8, :max 30}]]]",
      "type": "malli.core/missing-key",
      "message": "missing required key"
    },
    {
      "path": [
        "password"
      ],
      "in": [
        "password"
      ],
      "schema": "[:map {:closed true} [:email [:re #\"^.+@.+\\..+\"]] [:password [:string {:min 8, :max 30}]]]",
      "type": "malli.core/missing-key",
      "message": "missing required key"
    }
  ],
  "value": {
    "email": "",
    "password": "firepanda"
  },
  "type": "reitit.coercion/request-coercion",
  "coercion": "malli",
  "in": [
    "request",
    "body-params"
  ],
  "humanized": {
    "email": [
      "missing required key"
    ],
    "password": [
      "missing required key"
    ]
  }
}

dvingo15:02:38

value has email as string not a keyword

Casey17:02:30

Is it possible to instrument multimethods with the existing instrumentation features in malli?

👂 1
Ben Sless18:02:52

Won't multi schema with the dispatch fn itself cover it?

Casey18:02:48

Perhaps yes.. but then I have to define all schemas on multi-schema on the dispatch fn itself. I'd rather keep the schemas with the defmethod rather than defmulti.

ikitommi18:02:45

How would you like to define the schemas with defmethod?

Casey22:02:05

That's a good question.. defmethod doesn't support metadata afair..only the defmulti does. :thinking_face: Hmm

crimeminister21:02:07

I've got a user-supplied value stored in a map that is a malli schema. I would like to validate that the schema itself is valid; is there a predefined way to do so, or should I author my own "meta-schema" for checking my schema data?