I hope you are very well.
Right now I am developing a custom annotation to validates the arguments in a method, of this way:
Interface:
@Target({METHOD})
@Retention(RUNTIME)
@Constraint(validatedBy = ValidarImpl.class)
public @interface Validar {
public abstract String message() default "ERROR VALIDATION";
public abstract Class<?>[] groups() default {};
public abstract Class<? extends Payload>[] payload() default {};
}
Class:
public class ValidarImpl implements ConstraintValidator<Validar, Object> {
@Override
public boolean isValid(Object value, ConstraintValidatorContext context) {
return false;
}
}
Implementation of the annotation:
@Validar
public void method1 (@Positive int value, @Valid Car car){}
I am trying to obtain the name of the parameters and their value from ConstraintValidatorContext class with the intention validate the arguments of method1 method, however I haven't been able to do it yet
I would like to do something like this: How can I validate two or more fields in combination? with methods.
Thanks for your help.