electricitymaps / bloom-contrib

Making carbon footprint data available to everyone.
https://www.bloomclimate.com
MIT License
434 stars 104 forks source link

Less greedy modelCanRun for ingredients model #496

Closed skovhus closed 3 years ago

skovhus commented 3 years ago

https://github.com/tmrowco/bloom/issues/404

Adjust modelCanRun for ingredients model to not be as greedy.

To me this shows that we need a better way of annotating the supported types and how to not duplicate modelCanRun and the validation done in the model.

I suggest we investigate https://github.com/colinhacks/zod or https://github.com/pelotom/runtypes

skovhus commented 3 years ago

@corradio was it ever a design concern for modelCanRun to not use external data like getEntryByKey that I use here?

corradio commented 3 years ago

@corradio was it ever a design concern for modelCanRun to not use external data like getEntryByKey that I use here?

It wasn't a concern that I remember of. In general I tried to have pretty general modelCanRun in order to have better error messages ("No model found" vs "Incorrect line identifier for purchase")