Uploaded image for project: 'Stripes'
  1. STS-877

Meaningful error message when an "on" in @Validate annotation is an empty String

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects versions: Release 1.5.6
    • Fix versions: Release 1.5.7, Release 1.6
    • Components: Validation
    • Labels:
      None
    • Sprint:

      Description

      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:

      ### 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);
                       }
      

        Attachments

          Activity

            People

            • Assignee:
              bengunter BenB
              Reporter:
              yannik Yannik Hampe
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: