ForbesLindesay / funtypes

Runtime validation for static types
MIT License
29 stars 4 forks source link

Generate mock objects from funtypes #44

Open wmonk opened 3 years ago

wmonk commented 3 years ago

This is a question about lib enhancements.

I've been evaluating runtypes recently for addition to our project, and recently came across a bunch of test which were implementing mock versions of a bunch of objects that would be candidates for runtyping. It occurred to me that having all the details inside a funtype about what an object could look like should allow you to easily create mock objects from the schema. Having something like a .generate method, or a funtypes-generate module would allow this library to serve a dual purpose instead of having to write your schema in a single use mock object generation library.

I came across runtypes-generate, which implements a similar kind of thing.

I've yet to dig into the source of either of those libraries yet, but do you have any thoughts on the feasibility of something like this, or where it should live?