You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by liny <in...@gmail.com> on 2008/06/03 16:16:45 UTC

Multi-validator in one input field?

Hi,

I want to have a text field that can validate multi values, like below:

FormComponent fc;
fc = new RequiredTextField("name");
fc.add(StringValidator.minimumLength(8));
fc.add(new PatternValidator("cab\\d{2}"));
fc.add(new PatternValidator("[aAxX]\\d{7}")); 

I hope the value of this text field is valid when I type cab12 or a1234567.
But only first Pattern Validator works.
It means that if I input a1234567, validator says it's wrong.
If I input cab12, it's valid.
How can I archive the goal of multi validators in one text field?
Thanks!
-- 
View this message in context: http://www.nabble.com/Multi-validator-in-one-input-field--tp17624619p17624619.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Multi-validator in one input field?

Posted by liny <in...@gmail.com>.
Thanks, igor and Edvin!


Edvin Syse wrote:
> 
> In this case you could quite easily combine these in a single regexp.
> 
> -- Edvin
> 
>> all added validators are ANDed together. if you want to add an OR you
>> have to roll your own validator.
>>
>> -igor
>>
>> On Tue, Jun 3, 2008 at 7:16 AM, liny <in...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I want to have a text field that can validate multi values, like below:
>>>
>>> FormComponent fc;
>>> fc = new RequiredTextField("name");
>>> fc.add(StringValidator.minimumLength(8));
>>> fc.add(new PatternValidator("cab\\d{2}"));
>>> fc.add(new PatternValidator("[aAxX]\\d{7}"));
>>>
>>> I hope the value of this text field is valid when I type cab12 or
>>> a1234567.
>>> But only first Pattern Validator works.
>>> It means that if I input a1234567, validator says it's wrong.
>>> If I input cab12, it's valid.
>>> How can I archive the goal of multi validators in one text field?
>>> Thanks!
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Multi-validator-in-one-input-field--tp17624619p17624619.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Multi-validator-in-one-input-field--tp17624619p17627172.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Multi-validator in one input field?

Posted by ed...@sysedata.no.
In this case you could quite easily combine these in a single regexp.

-- Edvin

> all added validators are ANDed together. if you want to add an OR you
> have to roll your own validator.
>
> -igor
>
> On Tue, Jun 3, 2008 at 7:16 AM, liny <in...@gmail.com> wrote:
>>
>> Hi,
>>
>> I want to have a text field that can validate multi values, like below:
>>
>> FormComponent fc;
>> fc = new RequiredTextField("name");
>> fc.add(StringValidator.minimumLength(8));
>> fc.add(new PatternValidator("cab\\d{2}"));
>> fc.add(new PatternValidator("[aAxX]\\d{7}"));
>>
>> I hope the value of this text field is valid when I type cab12 or
>> a1234567.
>> But only first Pattern Validator works.
>> It means that if I input a1234567, validator says it's wrong.
>> If I input cab12, it's valid.
>> How can I archive the goal of multi validators in one text field?
>> Thanks!
>> --
>> View this message in context:
>> http://www.nabble.com/Multi-validator-in-one-input-field--tp17624619p17624619.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Multi-validator in one input field?

Posted by Igor Vaynberg <ig...@gmail.com>.
all added validators are ANDed together. if you want to add an OR you
have to roll your own validator.

-igor

On Tue, Jun 3, 2008 at 7:16 AM, liny <in...@gmail.com> wrote:
>
> Hi,
>
> I want to have a text field that can validate multi values, like below:
>
> FormComponent fc;
> fc = new RequiredTextField("name");
> fc.add(StringValidator.minimumLength(8));
> fc.add(new PatternValidator("cab\\d{2}"));
> fc.add(new PatternValidator("[aAxX]\\d{7}"));
>
> I hope the value of this text field is valid when I type cab12 or a1234567.
> But only first Pattern Validator works.
> It means that if I input a1234567, validator says it's wrong.
> If I input cab12, it's valid.
> How can I archive the goal of multi validators in one text field?
> Thanks!
> --
> View this message in context: http://www.nabble.com/Multi-validator-in-one-input-field--tp17624619p17624619.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org