@smchugh230395 can you use a set as the collection type?
That's a good idea but there is an order on the elements of the collection in my particular use-case. I can set up other ways of ensuring that only unique items enter the collection though so it isn't critical that Malli supports it out of the box.
I see. So “ordered set” is what you need I guess.
(m/validate [:and [:sequential any?] (fn [c] (= (count c) (count (set c))))
something like this?
JSON Schema has “uniqueItems” attribute, I guess sequences could have :distict
boolean property?
https://json-schema.org/understanding-json-schema/reference/array.html#uniqueness
… would be [:sequential {:distinct true} any?]
interesting
I am somewhat meh on the coupling to json schema
is there some usecase or justification i am missing?
good one, I think i'll go with this
Pretty sure this one of the least optimized way to check for distinct elements (reduce (fn [xs x] (if (xs s) (reduced false) (conj xs s))) #{} coll)
might be faster.