-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate 5.2.1 Reference Guide: Example 2.3 @ValidPart
PostPosted: Fri Aug 14, 2015 3:11 pm 
Newbie

Joined: Fri Aug 14, 2015 3:02 pm
Posts: 1
In the Hibernate 5.2.1 Reference Guide, In the Example 2.3 there is mention of annotation @ValidPart in line 4. Is this a typo?
There is no mention of ValidPart in the rest of the reference guide.

Here is the link to the reference guide:
http://docs.jboss.org/hibernate/validator/5.2/reference/en-US/html/

Below is the content of Example 2.3. Type argument constraint on List
Code:
package org.hibernate.validator.referenceguide.chapter02.typeargument;
public class Car {
@Valid
private List<@ValidPart String> parts = new ArrayList<>();
public void addPart(String part) {
parts.add( part );
}
//...
}
Car car = Car();
car.addPart( "Wheel" );
car.addPart( null );
Set<ConstraintViolation<Car>> constraintViolations = validator.validate( car );
assertEquals( 1, constraintViolations.size() );
assertEquals(
"'null' is not a valid car part.",
constraintViolations.iterator().next().getMessage()
);
assertEquals( "parts[1]",
constraintViolations.iterator().next().getPropertyPath().toString() );


Top
 Profile  
 
 Post subject: Re: Hibernate 5.2.1 Reference Guide: Example 2.3 @ValidPart
PostPosted: Tue Aug 25, 2015 2:26 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
Hi,

It's not a typo, @ValidPart is supposed to be a custom (type-use level) constraint which is meant to make sure that a given String is a valid part code or similar. Together with the @Valid annotation it is used to make sure that each element of the "parts" list is a valid part.

I have opened https://hibernate.atlassian.net/browse/HV-1014 to clarify this in the reference guide. Would you maybe interested in sending in a pull request for this?

Thanks for pointing out that issue,

--Gunnar

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.