Lab validation back-end fix
This PR turned out longer and less focused than I intended so I don't expect everything to be accepted.
What does this mr do?
Makes sure exam labs are properly validated. Closes: #345 (closed)
Actions taken to fix bug
I've added 2 ways to verify a lab.
- Through
LabValidator
. This makes sure that a bad@Validated
Lab form get's stopped at the web layer during theBindingResult
validation. - Through a custom
ConstraintValidator
.
...
@ValidExamLab
public class Lab implements Serializable {
...
This makes sure that upon any Lab
entity's lifecyle events it gets validated and exam labs don't have null percentage, otherwise throws a ConstraintValidationException
. This should make sure no bad labs get persisted while keeping the @Nullable
annotation.
I noticed that Lab
has a custom getter that returns 0 if the examLabPercentage is null. I've removed this since it breaks validation. Do you maybe need a custom serializer for this?
If you like this validation pattern I can expand it to other classes who may have similar issues.
Does this MR meet the acceptance criteria?
-
I have added a changelog entry to reflect the significant changes I made and the bug I fixed. -
A test was created to test the bug. -
I have updated the documentation accordingly. -
I adhere to the style guide.
Edited by Otto Visser