@Controller @Profile(value="resthub-validation") @RequestMapping(value="/api/validation") public class ValidationController extends Object
appContext.getEnvironment().setActiveProfiles("resthub-validation");
Constructor and Description |
---|
ValidationController() |
Modifier and Type | Method and Description |
---|---|
ModelConstraint |
getConstraintsForClassName(String canonicalClassName,
String locale)
Exposes an "/api/validation/{canonicalClassName}" endpoint to get all validation constraints for a given
object className and optional locale parameter.
|
void |
setService(ValidationService validationService) |
@Inject @Named(value="validationService") public void setService(ValidationService validationService)
@RequestMapping(value="{canonicalClassName:.+}", method=GET) @ResponseBody public ModelConstraint getConstraintsForClassName(@PathVariable String canonicalClassName, @RequestParam(required=false) String locale)
http://{host}:{port}/api/validation/org.resthub.validation.model.User http://{host}:{port}/api/validation/org.resthub.validation.model.User?locale=en-us
canonicalClassName
- mandatory path parameter containing the complete className of the Java Bean to export
(i.e. package + className - e.g. org.resthub.validation.model.User
).locale
- optional request parameter, the API takes the locale string indicating your internationalization preferences.
You can then provide a valid i18n locale string to choose the desired message locale.
Available locales are those supported by Hibernate Validator or provided by your custom properties files. If no locale
parameter is provided or if the locale parameter is invalid, the default server locale is used.ModelConstraint
instance containing representation of all validation constraints for
the given className.NotFoundException
- if either canonicalClassName is missing or could not be retrieved.ValidationService.getConstraintsForClassName(java.lang.String)
,
ModelConstraint
Copyright © 2009–2014. All rights reserved.