malli icon indicating copy to clipboard operation
malli copied to clipboard

Equality (or equivalence) definition

Open pfeodrippe opened this issue 4 years ago • 1 comments

Regarding equality, should both

  (mu/equals [:map
              [:id int?]
              [:b int?]]
             [:map
              [:b int?]
              [:id int?]])
  ;; => false

and

  (mu/equals [:map
              [:id [:or string? int?]]
              [:b int?]]
             [:map
              [:id [:or int? string?]]
              [:b int?]])
  ;; => false

return true?

Right now I can generate samples from one and validate with the other schema as a quick tests (but with no guarantees).

pfeodrippe avatar Aug 28 '21 03:08 pfeodrippe

It depends. If you generate a web-form out of the two, the order matter and the forms would look different. For validators, generators etc, they behave the same way. But, Schemas could implement equality via better means than form diffing (the current impl in mu/equals), which is slow.

ikitommi avatar Aug 29 '21 16:08 ikitommi