plumatic / schema

Clojure(Script) library for declarative data description and validation
Other
2.41k stars 257 forks source link

Add leaf generator for s/Uuid #280

Closed benalbrecht closed 9 years ago

w01fe commented 9 years ago

Thanks for the PR! As mentioned above, this isn't strictly correct. If you want to propose a correct version that's generic (and hopefully, not too complicated), we'd be happy to add it. Otherwise, if you don't really care about determinism, you should be able to use this version yourself without any changes to core (by passing it in as a leaf-generator).

benalbrecht commented 9 years ago

Sure, i forgot about the seed. I changed the code to generate a type 3 UUID using UUID/nameUUIDFromBytes. This function receives a byte array generated by test.check.generators as input. Since this type of uuid is basically an md5 hash [1], supplying the same byte array results in the same uuid.

[1] https://en.wikipedia.org/wiki/Universally_unique_identifier#Version_3_.28MD5_hash_.26_namespace.29

w01fe commented 9 years ago

Looks good, thanks!