mammoth-eu / mammoth-commons

Other
0 stars 6 forks source link

Validation of User Input #26

Open sudhang opened 3 hours ago

sudhang commented 3 hours ago

Hello

I have a component set up in the mammoth-commons project. I suppose the idea is that when we view the component via the toolkit, the User may provide some data (eg: a CSV file, some parameters etc)

Since the component doesn't control the UI, what is the best way to validate the input from the user? In our case, we need to ensure that the input matches our expectations. For now, the approach we are taking is to simply raise an exception. Does the toolkit rely on exceptions for such validation?

Thanks Sudhang

maniospas commented 3 hours ago

Hi, I can't speak for the toolkit since it is not at the stage of properly handling errors, but the demonstrator at least works properly if you raise exceptions on invalid conditions.This has the benefit of also catching dependent library exceptions if they perform internal validation, plus anything we might forget to catch.

I imagine it is small issue to do the same with the toolkit, so let us consider this mechanism the final one. In case something else is implemented, I will add it in the decorator anyway, so there will be no future overhead.

For example, run the demonstrator app and give something invalid as a dataset input to see how it handles the error.