KubeJS

KubeJS

61M Downloads

recipe key validators

rlnt opened this issue · 0 comments

commented

Describe the feature

Discussed this a little on Discord but I'll submit it here so you can keep track of it (and don't accidentally forget about it 🫠).

For the recipe schema system, it would be nice to be able to attach a validation consumer to RecipeKeys. The consumer will get the value that was passed to the specific RecipeKey, so you can validate the input.
This can be used if you accept an array of InputItems for example to ensure the array has the correct length.

Additional info

The current alternative is to validate the recipe inside a custom RecipeJS implementation via RecipeJS#afterLoaded as stated in its java doc. However, that currently swallows exceptions thrown by it which is probably also something worth reporting.

This approach would avoid the requirement to have a custom RecipeJS implementation. Also, this allows devs to use pre-defined RecipeComponents for different purposes as they can be validated individually.