Perform request body validation. You can use javax.validation library (for Spring Boot 3 use jakarta instead). Rules for validation are:
integer
field must not be null and must be non-negativedecimal
field must not be null and must be negativetext
field must not be null and must have length between 8 and 16 charactersdata
have a more complex rules:- when
magicLogicFlag
is set totrue
, thenmagicLogicField
must have a non-empty value - when
magicLogicFlag
is set tofalse
, thenmagicLogicField
can be empty or null
- when
Rules are covered with test cases.