[JIRA] Created: (STS-877) Meaningful error message when an "on" in @Validate annotation is an empty String

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[JIRA] Created: (STS-877) Meaningful error message when an "on" in @Validate annotation is an empty String

JIRA jira@stripesframework.org
Meaningful error message when an "on" in @Validate annotation is an empty String
--------------------------------------------------------------------------------

                 Key: STS-877
                 URL: http://www.stripesframework.org/jira/browse/STS-877
             Project: Stripes
          Issue Type: Improvement
          Components: Validation
    Affects Versions: Release 1.5.6
            Reporter: Yannik Hampe
            Priority: Minor


If a property has an annotation @Validate(on="") this is an error. I accidentally did just this in my project and it took me some time to figure out where the weird exception was coming from.

I propose to add a more meaningful error message for example with the help of the following patch:

{code:java}
### Eclipse Workspace Patch 1.0
#P stripes
Index: stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java
===================================================================
--- stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (revision 1487)
+++ stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (working copy)
@@ -205,9 +205,13 @@
             this.on = null;
         }
         else {
+         if (on[0].isEmpty())
+         throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
             this.on = new HashSet<String>();
             this.onIsPositive = !(on[0].charAt(0) == '!');
             for (String s : on) {
+             if (s.isEmpty())
+             throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
                 if (this.onIsPositive) {
                     this.on.add(s);
                 }
{code}

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Stripes-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-development
Reply | Threaded
Open this post in threaded view
|

[JIRA] Resolved: (STS-877) Meaningful error message when an "on" in @Validate annotation is an empty String

JIRA jira@stripesframework.org

     [ http://www.stripesframework.org/jira/browse/STS-877?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ben Gunter resolved STS-877.
----------------------------

       Resolution: Fixed
    Fix Version/s: Release 1.6
                   Release 1.5.7
         Assignee: Ben Gunter

> Meaningful error message when an "on" in @Validate annotation is an empty String
> --------------------------------------------------------------------------------
>
>                 Key: STS-877
>                 URL: http://www.stripesframework.org/jira/browse/STS-877
>             Project: Stripes
>          Issue Type: Improvement
>          Components: Validation
>    Affects Versions: Release 1.5.6
>            Reporter: Yannik Hampe
>            Assignee: Ben Gunter
>            Priority: Minor
>             Fix For: Release 1.5.7, Release 1.6
>
>
> If a property has an annotation @Validate(on="") this is an error. I accidentally did just this in my project and it took me some time to figure out where the weird exception was coming from.
> I propose to add a more meaningful error message for example with the help of the following patch:
> {code:java}
> ### Eclipse Workspace Patch 1.0
> #P stripes
> Index: stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java
> ===================================================================
> --- stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (revision 1487)
> +++ stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (working copy)
> @@ -205,9 +205,13 @@
>              this.on = null;
>          }
>          else {
> +         if (on[0].isEmpty())
> +         throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
>              this.on = new HashSet<String>();
>              this.onIsPositive = !(on[0].charAt(0) == '!');
>              for (String s : on) {
> +             if (s.isEmpty())
> +             throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
>                  if (this.onIsPositive) {
>                      this.on.add(s);
>                  }
> {code}

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Stripes-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-development
Reply | Threaded
Open this post in threaded view
|

[JIRA] Commented: (STS-877) Meaningful error message when an "on" in @Validate annotation is an empty String

JIRA jira@stripesframework.org
In reply to this post by JIRA jira@stripesframework.org

    [ http://www.stripesframework.org/jira/browse/STS-877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12800#comment-12800 ]

Danilo Ghirardelli commented on STS-877:
----------------------------------------

Using the {{.isEmpty()}} breaks the compatibility with Java 1.5, because is Java 1.6 only. I opened STS-890 to use another way to check the string.

> Meaningful error message when an "on" in @Validate annotation is an empty String
> --------------------------------------------------------------------------------
>
>                 Key: STS-877
>                 URL: http://www.stripesframework.org/jira/browse/STS-877
>             Project: Stripes
>          Issue Type: Improvement
>          Components: Validation
>    Affects Versions: Release 1.5.6
>            Reporter: Yannik Hampe
>            Assignee: Ben Gunter
>            Priority: Minor
>             Fix For: Release 1.5.7, Release 1.6
>
>
> If a property has an annotation @Validate(on="") this is an error. I accidentally did just this in my project and it took me some time to figure out where the weird exception was coming from.
> I propose to add a more meaningful error message for example with the help of the following patch:
> {code:java}
> ### Eclipse Workspace Patch 1.0
> #P stripes
> Index: stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java
> ===================================================================
> --- stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (revision 1487)
> +++ stripes/src/net/sourceforge/stripes/validation/ValidationMetadata.java (working copy)
> @@ -205,9 +205,13 @@
>              this.on = null;
>          }
>          else {
> +         if (on[0].isEmpty())
> +         throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
>              this.on = new HashSet<String>();
>              this.onIsPositive = !(on[0].charAt(0) == '!');
>              for (String s : on) {
> +             if (s.isEmpty())
> +             throw new IllegalArgumentException("the on property of a @Validate annotation must not be an empty string");
>                  if (this.onIsPositive) {
>                      this.on.add(s);
>                  }
> {code}

--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Stripes-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-development