I was wondering if being able to leverage the annotations for parameter calls would be considered out of scope for 303, for example, say my web framework mapped functions to URL endpoints and parameters to query/post parameters:
Code:
@Valid
String doLogin(@NotNull @Length(16) String username, @NotNull @Length(16) String password) { ... }
Assuming the annotations were valid on parameters, processing might look something like this pseudocode:
Code:
value process(Method method, HttpServletRequest request ) {
if (method annotated with Valid) {
for (each parameter on method) {
create or lookup validator appropriate to method and given annotations
run annotations through
alter any returned invalid constraints to represent the parameter name in their path
append returned invalid constraints to master set
}
}
if (any invalid constraints found) {
throw exception to switch to handle invalid parameters
}
invoke method with parameters and return appropriate result
}
However, today this would have to build some sort of model objects, as parameters cannot have the standard annotations.[/code]