PowerSystemDataModel icon indicating copy to clipboard operation
PowerSystemDataModel copied to clipboard

Include boolean flag for automatic Validation when constructing a `JointGridContainer` or even any Entity

Open t-ober opened this issue 3 years ago • 3 comments

We have a lot of ValidationUtils that check assets and participants for validity of attributes (can be called by ValidationUtils.check() for any entity and delegates to the respective method). It would be nice to be able to trigger them automatically when creating a JointGridContainer by for example including a boolean flag validate. Which could be set to False by default to not break existing code.

This could even be done for every entity.

t-ober avatar Feb 16 '23 09:02 t-ober

Maybe the solution would be to make validation better known in the documentation? If we want such a flag, I think it should not be used as a parameter to the constructor of JointGridContainer (constructors should just do what their name says), but as a flag in the methods that build the container.

sebastian-peter avatar Feb 16 '23 10:02 sebastian-peter

Isn't it quite common in constructors to check the arguments that are passed for validity?

But I agree if we would pass that somehow as an argument we would have a single argument that isn't supposed to be an attribute of the object but a modification of the construction.

In any case we definitely should make that more popular. We do not even use it in Simona at the moment. -> https://github.com/ie3-institute/simona/issues/460

t-ober avatar Feb 16 '23 10:02 t-ober

Ok reading more into what seems to be convention around constructors and validation, I'd be fine doing it in the constructor or close to it

sebastian-peter avatar Feb 16 '23 13:02 sebastian-peter