Great suggestions. I'll add this when I get a chance (I'm at JavaOne
this week, so I'm not sure when that is :-))

> -----Original Message-----
> From: Cameron Braid [mailto:[EMAIL PROTECTED] 
> Sent: Monday, June 09, 2003 1:21 AM
> To: [EMAIL PROTECTED]
> Subject: [OS-webwork] Xwork validators
> 
> 
> I am starting to use the XWork validation system.
> 
> I think it is a great, simple system.
> 
> A few changes that I suggest are :
> 
> AbstractRangeValidator
> ----------------------
> 
> Currently, if the value to be validated is null, a NPE is 
> thrown, this can't be avoided even by inserting a required 
> validator, as all validators are executed with the interceptor.
>   - I suggest that if the value is null to skip the comparison step.
>   - If a value is required, a required validator should be 
> added, then this range interceptor can have an effect.
> 
> Also, it would be nice to use the range validators to check either
>   - just min
>   - just max
>   - both min and max
> 
> Here is the code :
> 
>     public void validate(Action action) throws ValidationException {
>         Comparable value = (Comparable) 
> this.getFieldValue(getFieldName(),
> action);
> 
>         // if there is no value - don't do comparison
>         // if a value is required, a required validator 
> should be added to the field
>         if (value == null)
>         {
>               return;
>         }             
>         
>         // only check for a minimum value if the min parameter is set
>         if (getMinComparatorValue() != null &&
> value.compareTo(getMinComparatorValue()) < 0)
>         {
>                       addFieldError(getFieldName(), action);
>         }
>                       
>               // only check for a maximum value if the max 
> parameter is
> set
>         if (getMaxComparatorValue() != null &&
> value.compareTo(getMaxComparatorValue()) > 0)
>         {
>                       addFieldError(getFieldName(), action);
>         }
>     }
> 
> IntRangeValidator
> -----------------
> 
> Change min and max defaults to be null rather that Integer(0)
> 
> 
> I have added a Jira task for this comment
> 
> 
http://jira.opensymphony.com/secure/ViewIssue.jspa?key=WW-210



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork


-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to