Here is example about method validation. So check method paramerter as not null I have to write the follolwing:
import org.springframework.validation.annotation.Validated
@Validated
public class SomeClass {
public void myMethod(@NotNull Object p1, @Nullable Object p2) {}
}
Is there a way to setup spring bean validation to make all parameters validated as @NotNull
by default? E.g. the following will fail when p1
is null
:
import org.springframework.validation.annotation.Validated
@Validated
public class SomeClass {
public void myMethod(Object p1, @Nullable Object p2) {}
}
Any ideas?
You can write your own
@NotNullArgs
annotation as an optionAnd aspect:
Then you can use it like this:
It's just a draft, but you can use this code as a point to start