-
Notifications
You must be signed in to change notification settings - Fork 397
WICKET-6499 Support Bean Validation 2.0 #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
40824aa to
fd07047
Compare
|
|
||
| HashSet<Class<?>> validatorGroups = new HashSet<Class<?>>(); | ||
| HashSet<Class<?>> validatorGroups = new HashSet<>(); | ||
| validatorGroups.addAll(Arrays.asList(getGroups())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use Set here
|
|
||
| for (NotNull constraint : constraints) | ||
| for (Annotation constraint : constraints.keySet()) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entrySet() can be used here to avoid double search
fd07047 to
46b4634
Compare
|
@solomax: Thanks for the quick feedback. I adjusted the PR accordingly. |
| { | ||
| if (canApplyToDefaultGroup(constraint) && validatorGroups.isEmpty()) | ||
| final Annotation annotation = entry.getKey(); | ||
| ConstraintDescriptor<?> constraintDescriptor = constraints.get(annotation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use entry.getValue() here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, totally overlooked that. Changed.
36fbc18 to
65e9d88
Compare
| <entry key="javax.validation.constraints.Max.message">Le champ '${label}' doit être inférieur ou égal à ${value}</entry> | ||
| <entry key="javax.validation.constraints.Min.message">Le champ '${label}' doit être supérieur ou égal à ${value}</entry> | ||
| <entry key="javax.validation.constraints.NotNull.message">Le champ '${label}' ne doit pas être null</entry> | ||
| <entry key="javax.validation.constraints.NotBlank.message">Le champ '${label}' ne peut pas être vide</entry> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for new labels, I'll add _ru localization ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added properties for English and French. My French is a bit rusty, but the translations should be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably copy the properties from the HV implementation:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is APL licensed so, I guess, we can copy
I would better use existing ones, but not sure how is this possible :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing ones could probably be loaded via a custom IStringResourceLoader but this is out of the scope of this PR.
@solomax: What else do you want me to do for this PR so it can be merged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK with me :)
65e9d88 to
a6e3268
Compare
|
Actually I'm wondering whether we should just add another method to ITagModifier (possibly with better names): This way we can use the identical lookup BeanValidationConfiguration#getTagModifier() to alter the component itself from #onConfigure() and the component tag from #onComponentTag(). All that's required for the new annotations is then: |
|
@svenmeier: This makes a lot of sense. I'm not sure however how much time I'll find the next weeks to work on this. I suggest the following approach:
WDYT? |
|
That's a very good approach, thank you. |
7579651 to
145e12e
Compare
|
I pushed the simplified implementation without API changes in 145e12e. |
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.lang.annotation.Annotation; | ||
| import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No * imports please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed
|
I believe this can be closed |
This PR adds support for Bean Validation 2.0 to
wicket-bean-validation.It extends scanning of
@NotNullannotations to@NotEmptyand@NotBlankand supports registering further annotations that should be treated as not-null constraints to guard against future changes.See https://issues.apache.org/jira/browse/WICKET-6499