You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by R Balaji <ba...@india.adventnet.com> on 2003/07/24 07:50:09 UTC
Validator Problem when using "Required"
Hi,
I am using Struts Validator for validating my Application. i am using
"required" for many of the fields and using minlength and maxlength for
the userName field.
my validation.xml reads like this,
/Ex :
<field property="lastName" depends="*required*">
<arg0 key="validateform.lastname"/>
</field>
<field property="userName"
depends="*required,minlength,maxlength*">
<arg0 key="validateform.userName" name="required"/>
<arg0 key="validateform.userName" name="minlength"/>
<arg1 key="${var:minlength}" name="minlength" resource="false"/>
<arg0 key="validateform.userName" name="maxlength"/>
<arg1 key="${var:maxlength}" name="maxlength" resource="false"/>
<var>
<var-name>minlength</var-name>
<var-value>5</var-value>
</var>
<var>
<var-name>maxlength</var-name>
<var-value>10</var-value>
</var>
</field>
<field property="age"
depends="*required*">
<arg0 key="validateform.age"/>
</field>/
If i fail to give the userName it is prompting, that userName is
required. But if i input only "2" characters for the userName, while all
other ( some of the other ) fields are empty it prompts only about all
other required fields, and not validating the *minlength* condition
until all other required conditions get satisfied. I feel it should also
validate the userName and prompt that the length is less than 5 chatacters.
is there anything to define the precedence in the validation.xml ? ..
will the minlength be validated only if all the required get satisfied. ??
please Help me.
TIA,
Balaji
Re: Validator Problem when using "Required"
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
R Balaji wrote:
> I think it would be better if we prompt all the errors at once to the
> user. The user should not wait till entering the valid fields and then
> check for the validity of the entered values.
>
> The "Required" condition should take the precedence over all other
> condition for that *particular Field*. I too agree this , as there is
> not point in checking the length, when the user fails to enter the value
> at all. But my concern is, why should we wait till entering all *other*
> required fields, for checking the length of a Field.
>
> Can i do Complex validations, using the predefined rules like
> "required", "range" .. etc .. ? Should i write my own rules by
> duplicating the predefined ones ?
That is your preference, but I feel the way it is currently done is
best. For the javascript validation on the client-side, this is
definitely better because the errors appear in a small pop-up which you
have to click away before you can correct the errors, i.e. the user has
to memorise the errors before correcting them.
On the server-side I agree it is probably preferable to show all errors
at once.
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: Validator Problem when using "Required"
Posted by R Balaji <ba...@india.adventnet.com>.
Adam Hardy wrote:
> R Balaji wrote:
>
>> If i fail to give the userName it is prompting, that userName is
>> required. But if i input only "2" characters for the userName, while
>> all other ( some of the other ) fields are empty it prompts only
>> about all other required fields, and not validating the *minlength*
>> condition until all other required conditions get satisfied. I feel
>> it should also validate the userName and prompt that the length is
>> less than 5 chatacters.
>>
>> is there anything to define the precedence in the validation.xml ? ..
>> will the minlength be validated only if all the required get
>> satisfied. ??
>
>
> I'm not sure but that's the way my validation functions as well. I
> imagine the validator has certain rules such as this built in so that
> you don't get overwhelmed with validation messages when you have
> complex validations to do.
>
> How can that be a problem though?
I think it would be better if we prompt all the errors at once to the
user. The user should not wait till entering the valid fields and then
check for the validity of the entered values.
The "Required" condition should take the precedence over all other
condition for that *particular Field*. I too agree this , as there is
not point in checking the length, when the user fails to enter the value
at all. But my concern is, why should we wait till entering all *other*
required fields, for checking the length of a Field.
Can i do Complex validations, using the predefined rules like
"required", "range" .. etc .. ? Should i write my own rules by
duplicating the predefined ones ?
>
>
> Adam
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
Re: Validator Problem when using "Required"
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
R Balaji wrote:
> If i fail to give the userName it is prompting, that userName is
> required. But if i input only "2" characters for the userName, while all
> other ( some of the other ) fields are empty it prompts only about all
> other required fields, and not validating the *minlength* condition
> until all other required conditions get satisfied. I feel it should also
> validate the userName and prompt that the length is less than 5 chatacters.
>
> is there anything to define the precedence in the validation.xml ? ..
> will the minlength be validated only if all the required get satisfied. ??
I'm not sure but that's the way my validation functions as well. I
imagine the validator has certain rules such as this built in so that
you don't get overwhelmed with validation messages when you have complex
validations to do.
How can that be a problem though?
Adam
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org