Re: Re: complex validation problem.

2006-04-29 Thread Jakub Milkiewicz

Hi
Thanks for all answers. Finally i created 2 new validators: skipNextIf and
gotoNextIf.
They both test some expression which is passed in var-value parameter and if
the expression is evaluated to true,
skipNextIf return false and gotoNextIf return true. As you can imagine, i do
not add any entries to Errors in these validators .
They just work only as some kind of gateway which can break the the
validation  chain for a property.
  milus

2006/4/28, Chaudhary, Harsh <[EMAIL PROTECTED]>:


You could write a custom validator which would read the value of the
documentIdentity. Then,

If
documentIdentity != "pazport", return true
else
-- Run your mask validation for passport number --

To do the mask validation, from your class, consult this:
http://struts.apache.org/struts-action/struts-core/apidocs/index.html

Look for a method: validateMask()

Harsh.

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
Sent: Friday, April 28, 2006 4:37 PM
To: user@struts.apache.org
Subject: Re: complex validation problem.


Jakub Milkiewicz wrote:
> Hi
> I have a problem with conditional validation. Currently i am working
with
> struts 1.1 - because of its WSAD support but i am thinking of
migrating to
> the newest one.
> My problem is that on my jsp page i have 2 radio buttons:
> 
> 
> I am using struts validator and in my validation.xml i want to have
> passportNumber property validated IF AND ONLY IF documentIdentity
equals
> paszport.
> More, i want to have it validated with other validators too.
> I need something like:
>   depends="requiredif,mask" page="1">
>  
>   field[0]
> documentIdentity
>   
>   
> fieldTest[0]
> EQUAL
>   
>   
> fieldValue[0]
> paszport
>   
>   
>mask
>${passportNumberMask}
>  
> 
> So if documentIdentity.equals paszport, passportNumber  is required
and
> needs to be validated against mask validator.
> If doucmentIdentity eqauls dowod, i do not wanna to validate
passportNumber
> at all.
> Can struts validator satisfy my requirements? Can struts 1.1 validator
> satisfy it??
> I have spent a lot of time on struts mailing list trying to find an
answer
> for my problem but i haven't found anything special.
> Maybe solution presented in
> http://marc.theaimsgroup.com/?l=struts-user&m=113029818225923&w=2
> is suggested in Struts.
> Can anyone help me.

Unfortunately the validation framework doesn't support this requirement
directly; when you say depends="requiredif,mask", this is taken to mean
'the field is valid if it passed the requiredif test AND it passes the
mask test'. There's no way to have a requiredif/validwhen rule control
whether another rule is applied.

The message you referenced in the archives looks like a good starting
point to achieve what you want. Essentially, you will need to write your

own validation rule. That message looks like it details a reasonably
flexible basis for doing so.

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Re: complex validation problem.

2006-04-28 Thread Chaudhary, Harsh
You could write a custom validator which would read the value of the
documentIdentity. Then,

If 
documentIdentity != "pazport", return true
else
-- Run your mask validation for passport number --

To do the mask validation, from your class, consult this:
http://struts.apache.org/struts-action/struts-core/apidocs/index.html

Look for a method: validateMask()

Harsh.

-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper
Sent: Friday, April 28, 2006 4:37 PM
To: user@struts.apache.org
Subject: Re: complex validation problem.


Jakub Milkiewicz wrote:
> Hi
> I have a problem with conditional validation. Currently i am working
with
> struts 1.1 - because of its WSAD support but i am thinking of
migrating to
> the newest one.
> My problem is that on my jsp page i have 2 radio buttons:
> 
> 
> I am using struts validator and in my validation.xml i want to have
> passportNumber property validated IF AND ONLY IF documentIdentity
equals
> paszport.
> More, i want to have it validated with other validators too.
> I need something like:
>   depends="requiredif,mask" page="1">
>  
>   field[0]
> documentIdentity
>   
>   
> fieldTest[0]
> EQUAL
>   
>   
> fieldValue[0]
> paszport
>   
>   
>mask
>${passportNumberMask}
>  
> 
> So if documentIdentity.equals paszport, passportNumber  is required
and
> needs to be validated against mask validator.
> If doucmentIdentity eqauls dowod, i do not wanna to validate
passportNumber
> at all.
> Can struts validator satisfy my requirements? Can struts 1.1 validator
> satisfy it??
> I have spent a lot of time on struts mailing list trying to find an
answer
> for my problem but i haven't found anything special.
> Maybe solution presented in
> http://marc.theaimsgroup.com/?l=struts-user&m=113029818225923&w=2
> is suggested in Struts.
> Can anyone help me.

Unfortunately the validation framework doesn't support this requirement 
directly; when you say depends="requiredif,mask", this is taken to mean 
'the field is valid if it passed the requiredif test AND it passes the 
mask test'. There's no way to have a requiredif/validwhen rule control 
whether another rule is applied.

The message you referenced in the archives looks like a good starting 
point to achieve what you want. Essentially, you will need to write your

own validation rule. That message looks like it details a reasonably 
flexible basis for doing so.

L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: complex validation problem.

2006-04-28 Thread Laurie Harper

Jakub Milkiewicz wrote:

Hi
I have a problem with conditional validation. Currently i am working with
struts 1.1 - because of its WSAD support but i am thinking of migrating to
the newest one.
My problem is that on my jsp page i have 2 radio buttons:


I am using struts validator and in my validation.xml i want to have
passportNumber property validated IF AND ONLY IF documentIdentity equals
paszport.
More, i want to have it validated with other validators too.
I need something like:

 
  field[0]
documentIdentity
  
  
fieldTest[0]
EQUAL
  
  
fieldValue[0]
paszport
  
  
   mask
   ${passportNumberMask}
 

So if documentIdentity.equals paszport, passportNumber  is required and
needs to be validated against mask validator.
If doucmentIdentity eqauls dowod, i do not wanna to validate passportNumber
at all.
Can struts validator satisfy my requirements? Can struts 1.1 validator
satisfy it??
I have spent a lot of time on struts mailing list trying to find an answer
for my problem but i haven't found anything special.
Maybe solution presented in
http://marc.theaimsgroup.com/?l=struts-user&m=113029818225923&w=2
is suggested in Struts.
Can anyone help me.


Unfortunately the validation framework doesn't support this requirement 
directly; when you say depends="requiredif,mask", this is taken to mean 
'the field is valid if it passed the requiredif test AND it passes the 
mask test'. There's no way to have a requiredif/validwhen rule control 
whether another rule is applied.


The message you referenced in the archives looks like a good starting 
point to achieve what you want. Essentially, you will need to write your 
own validation rule. That message looks like it details a reasonably 
flexible basis for doing so.


L.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]