-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Related to (#666) avaje/avaje-http#666
and related to (#672) avaje/avaje-http#672
#672 implements a warning for avaje-http @Valid used outside of @Controller, which
is one of the issues that we face with the confusing / same annotation naming.
This issue is to request two things:
-
Issue a warning, if not already doing this, for usages of
avaje-validator @Valid(or the
@jakarta.validation.Validetc that we support) - given that the type has no actual
constraint usages declaredIs it easy to determine if no constraints are declared?
This update would do the same that#672does. -
Potentially more difficult update -
@ValidatorModuleannotation that goes on either
amodule-infoorpackage-infofor package/module-wide generation of validator adapters.This would have to walk the
exports(or the annotated package) to list out what types contain
usages of constraint annotations (annotations marked with@Constraint, etc).Then, the following example:
import io.avaje.validation.constraints.NotBlank; //@Valid not required record User(@NotBlank String name, int age) {}
...becomes all that is required to generate a validation adapter.
Whether that adapter is actually used with a call tovalidatedoesn't matter
An issue with this approach is similar to what @rbygrave said about "redundant
@Inject",
which also reminds me about Java not requiring@Override- a lot of these serve as a
documentation tool.I like it for
@Inject, I like it for@Controller @Valid, but I'm not sure if we need to say
that an adapter is being generated, if it never gets used anyway.Marking a module as
@ValidatorModulealready does give some "explicit-ness" to this?
(I chose that name here to be analogous to@InjectModule)