[bv-dev] Bean Validation and JAX-RS: conversion too?

Emmanuel Bernard emmanuel at hibernate.org
Mon Jul 15 02:44:57 EDT 2013


I have to admit I am not particularly experienced in the "conversion" / "transformation" field but my intuition follows what Matt has been describing. i.e. a separate specification to cover this.

Out of curiosity, do you Ed or anyone see specific adherence between Bean Validation and conversion? I can see a few thinking only a few minutes to the subject:

- one might want conversion after some input has been validated - coarse grained around "convertibility"? Or is that the whole responsibility of the converter?
- one might want validation after some input has been converted - fine grained

Any other adherence?

Emmanuel

On 12 juil. 2013, at 22:27, Edward Burns <edward.burns at oracle.com> wrote:

> Hello Volunteers,
> 
> I've been viewing Emmanuel's videos about BV 1.1 and whenever he talks
> about Bean Validation and JAX-RS, such as this
> 
> @Path("/user")
> class UserResource {
> 
>  @Post
>  @Consumes("application/x-www-form-urlencoded")
>  public void register(
>    @NotEmpty @FormParam("firstname") String firstname,
>    @NotEmpty @FormParam("lastname") String lastname,
>    @NotNull @Email @FormParam("email") String email) { ... }
> }
> 
> I have to ask myself, isn't this missing something?  What about
> conversion?
> 
> Before Bean Validation, JSF brought type conversion *and* validation to
> the table.  Now that Bean Validation provides the validation part for
> all of JavaEE, isn't it time we think about the other part: type
> conversion?
> 
> JSF has an elaborate conversion system with by-type conventions and also
> the ability to manually declare that specific converters should be used
> for specific values.  It's not a far cry to realize that we don't need
> to limit ourselves to "String" for these arguments and there is a lot we
> could do to enable arbitrary types and have Bean Validation handle the
> conversion on the way in.
> 
> JAX-RS also has the javax.ws.rs.ext.ParamConverter facility, which
> solves the conversion problem in a JAX-RS specific way.
> 
> Here we have two specs that do conversion.  I think it might be useful
> to realize that type conversion is really just the first part of
> validation, and therefore falls under the responsibility of Bean
> Validation.
> 
> Is this worth pursuing?
> 
> Ed
> 
> -- 
> _______________________________________________
> beanvalidation-dev mailing list
> beanvalidation-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/beanvalidation-dev



More information about the beanvalidation-dev mailing list