Freddy,
   Thanks. I wanted the ability to validate the individual elements so I
just wrote my own validation method that works on the output of
OneToManyTypeConvertor. I actually needed to do some duplicate checking in
there anyway so that worked out fine.

It would be nice to have a way to bridge

 @Validate(converter=OneToManyTypeConverter.class)
public List<Integer> numbers;

and

 @Validate(minvalue=1, maxvalue=5)
 public List<Integer> numbers;

together.









On Tue, Sep 8, 2009 at 12:54 PM, Freddy Daoud <[email protected]> wrote:

> Hi Ross,
>
> - Hi,  I'm using a OneToManyTypeConvertor to split a single input value
> - containing multiple MAC addresses separated by a comma separator into a
> list
> - of strings.I'd like to specify further validation rules on the format of
> - each MAC address. Is there a simple way to do this with the
> - OneToManyTypeConvertor? Can I specify an additional mask that applies to
> - each element?
>
> As far as I can tell, you can't specify additional validations to each
> element
> of a value converted with OneToManyTypeConverter. In your case, one
> possible
> but somewhat clumsy solution is to validate the value with a mask, but here
> you are validating the entire input, including commas and spaces between
> values. For example, to validate a list of values are all uppercase
> letters:
>
> @Validate(converter=OneToManyTypeConverter.class, mask="([A-Z]+(, +)?)+")
>
> Like I said, it is not a pretty solution and if there is a validation
> error,
> you just get one message saying that the entire input is not valid; you
> won't
> be told which value in the list caused the error.
>
> - I know I can create a MAC address type and then create a type convertor
> but
> - I am wondering if there is a simpler way of doing this.
>
> That's a cleaner way of going about it, or you can just use Strings but
> create
> your type converter and a subclass of OneToManyTypeConverter that overrides
> the method:
>
>  protected TypeConverter getSingleItemTypeConverter(Class targetType)
>
> in which you return your type converter.
>
> - Another example would
> - be where the user enters a list of numbers and you want to range check
> each
> - number entered.
>
> Certainly a valid feature, but again, as far as I can tell, you can't do
> this
> with OneToManyTypeConverter. E.g. this does not work:
>
>  @Validate(converter=OneToManyTypeConverter.class, minvalue=1, maxvalue=5)
>  public List<Integer> numbers;
>
> You *can* validate each number of the list:
>
>  @Validate(minvalue=1, maxvalue=5)
>  public List<Integer> numbers;
>
> but in this case each number has to be submitted separately instead of in a
> single String.
>
> Hope that helps.
>
> Cheers,
> Freddy
> http://www.stripesbook.com
>
>
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus
> on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Stripes-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/stripes-users
>



-- 
Ross Sargant
Software Engineer
p: 954-623-6018 x2108
email: [email protected]

TVR Communications LLC
541 S. State Road 7,Suite 5,Margate, Florida,33068

http://www.tvrc.com
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users

Reply via email to