Open jerseyrobot opened 15 years ago
@glassfishrobot Commented Reported by dirkm@java.net
@glassfishrobot Commented ccamel said: This feature will be great.
I think it would be interesting to use a set of annotations derived from JSR-305.
@glassfishrobot Commented This issue was imported from java.net JIRA JERSEY-351
Add more flexible parameter validation to Jersey.
In particular, the solution should at least include the ability to check if a parameter is present and raise an error if is not. In general and eventually the solution should allow flexible parameter validation.
Possible solutions:
1) Jersey supports an @Required annotation; or
2) Exposes a lower-level abstraction of MultivaluedParameterExtractor (which is an internally used interface):
public interface MultivaluedParameterExtractor
{ Object extract(MultivaluedMap<String, String> parameters); }
public interface MultivaluedParameterExtractorProvider { }
public interface MultivaluedParameterExtractorWorkers { }
and the same type of pattern can be utilized.
3) One can utilize AOP method-level interceptors to support @Required and check for a null value. This solution is much better if one needs to take into account more than one value.
I also wonder if there is a more general approach to parameter validation we can apply with the bean validation framework.
Environment
Operating System: All Platform: All URL: http://n2.nabble.com/Required-parameters-on-a-Resource-td3446928.html