You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Joseph Breuer (JIRA)" <ji...@apache.org> on 2006/11/15 22:37:37 UTC
[jira] Created: (VALIDATOR-207) Disabled fields should not be
checked by the validateRequired function. Relevant to adding the check for
field disabled in jcv_isFieldPresent.
Disabled fields should not be checked by the validateRequired function. Relevant to adding the check for field disabled in jcv_isFieldPresent.
-----------------------------------------------------------------------------------------------------------------------------------------------
Key: VALIDATOR-207
URL: http://issues.apache.org/jira/browse/VALIDATOR-207
Project: Commons Validator
Issue Type: Bug
Components: JavaScript
Affects Versions: 1.3.0 Release
Reporter: Joseph Breuer
For validateRequired the following condition checks to see if the field is present. It then sets the validity to false.
if (!jcv_isFieldPresent(field)) {
fields[i++] = oRequired[x][1];
isValid=false;
}
Supposedly validateRequired as well as all of the validate methods are not supposed to validate fields that are set as disabled. This method seems to categorize disabled fields with those that are null or are undefined.
validateRequired should differentiate between the disabled fields and the not present fields.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (VALIDATOR-207) Disabled fields should not be
checked by the validateRequired function. Relevant to adding the check for
field disabled in jcv_isFieldPresent.
Posted by "Joseph Breuer (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/VALIDATOR-207?page=comments#action_12450405 ]
Joseph Breuer commented on VALIDATOR-207:
-----------------------------------------
The only reason why I submitted this as a bug is that the previous version of validator would not check disabled fields for the required validation. During an upgrade to the most recent version of the validator an existing form that worked correctly before now would not make it past validation even though the hidden input field was marked disabled. We had to implement a work around, dropping the disabled attribute and putting in a dummy value to validate correctly.
According to the documentation for the validateRequired fields are not checked if they are disabled.
/*$RCSfile: validateRequired.js $ $Rev: 376673 $ $Date: 2006/11/08 10:31:38EST $ */
/**
* Check to see if fields must contain a value.
* Fields are not checked if they are disabled.
* <p>
* @param form The form validation is taking place on.
*/
That functionality was particularly useful in our case because we could reuse a form and the validation for the form for both the create and update functionality of an object. However for the update function we did not want the password to change so during the form creation we conditionally create the input field and make it disabled and hidden for updates.
It seems that for backwards compatibility and for consistency across the validate methods disabled fields should not be checked.
> Disabled fields should not be checked by the validateRequired function. Relevant to adding the check for field disabled in jcv_isFieldPresent.
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: VALIDATOR-207
> URL: http://issues.apache.org/jira/browse/VALIDATOR-207
> Project: Commons Validator
> Issue Type: Bug
> Components: JavaScript
> Affects Versions: 1.3.0 Release
> Reporter: Joseph Breuer
>
> For validateRequired the following condition checks to see if the field is present. It then sets the validity to false.
> if (!jcv_isFieldPresent(field)) {
> fields[i++] = oRequired[x][1];
> isValid=false;
> }
> Supposedly validateRequired as well as all of the validate methods are not supposed to validate fields that are set as disabled. This method seems to categorize disabled fields with those that are null or are undefined.
> validateRequired should differentiate between the disabled fields and the not present fields.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (VALIDATOR-207) Disabled fields should not be
checked by the validateRequired function. Relevant to adding the check for
field disabled in jcv_isFieldPresent.
Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/VALIDATOR-207?page=comments#action_12450229 ]
Niall Pemberton commented on VALIDATOR-207:
-------------------------------------------
Disabled fields are not submitted by the browser and so are effectively not present, which is why this method works this way.
For the "required" validator this means that the validation will fail - which I believe is correct, otherwise validation will pass even though whats submitted won't contain the "required" value. For the other validators it means that disabled fields are not validated.
So your statement "not supposed to validate fields that are set as disabled" is true for all the validators except "required". If you need the "required" validator to work differently, you can always plug in your own version, but as far as I'm concerned this is working as intended and so I'm planning to close this as "INVALID".
Niall
> Disabled fields should not be checked by the validateRequired function. Relevant to adding the check for field disabled in jcv_isFieldPresent.
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: VALIDATOR-207
> URL: http://issues.apache.org/jira/browse/VALIDATOR-207
> Project: Commons Validator
> Issue Type: Bug
> Components: JavaScript
> Affects Versions: 1.3.0 Release
> Reporter: Joseph Breuer
>
> For validateRequired the following condition checks to see if the field is present. It then sets the validity to false.
> if (!jcv_isFieldPresent(field)) {
> fields[i++] = oRequired[x][1];
> isValid=false;
> }
> Supposedly validateRequired as well as all of the validate methods are not supposed to validate fields that are set as disabled. This method seems to categorize disabled fields with those that are null or are undefined.
> validateRequired should differentiate between the disabled fields and the not present fields.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (VALIDATOR-207) Disabled fields should not be
checked by the validateRequired function. Relevant to adding the check for
field disabled in jcv_isFieldPresent.
Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/VALIDATOR-207?page=comments#action_12451948 ]
Niall Pemberton commented on VALIDATOR-207:
-------------------------------------------
You make a good point and I can't actually remember if this was an unintended consequence of the refactoring I did to use a common function (jcv_isFieldPresent) or not. Whatever the case though, you're right that the change isn't consistent with previous validator versions or what the docs indicate - my apologies for that.
Having said that I still think that disabled fields not being submitted to the server means that validation passes for fields marked as "required" that are missing - which seems incorrect to me. Also its a catch 22 situation in terms of compatibility - reverting the change will break consistency with Validator 1.3.0 and anyone now relying on the new behaviour.
Seeing your description of how you were using this behaviour also makes me think theres an alternative solution for your use-case which models more accurately what you're trying to achieve and doesn't rely on what IMO was broken validator behaviour. Since Validator 1.2.0 you can "inherit" validation rules - which means you could define you're update form rules and then inherit (re-use) them for you're create form, something like this:
<form name="updateUser">
<field property="name" depends="required">
...
</field>
</form>
<form name="createUser" extends="updateUser">
<field property="password" depends="required,minLength">
...
</field>
</form>
See http://wiki.apache.org/jakarta-commons/ValidatorVersion120
I guess if this doesn't satisfy your need then perhaps an alternative solution would be to keep the current Validator 1.3.0 behaviour, but provide a way to configure the required script validator to ignore disabled fields. I haven't thought much about this - but my initial thought is to introduce a new "ignoreDisabled" parameter/variable that the required validator checks - alternative suggestions welcome though.
> Disabled fields should not be checked by the validateRequired function. Relevant to adding the check for field disabled in jcv_isFieldPresent.
> -----------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: VALIDATOR-207
> URL: http://issues.apache.org/jira/browse/VALIDATOR-207
> Project: Commons Validator
> Issue Type: Bug
> Components: JavaScript
> Affects Versions: 1.3.0 Release
> Reporter: Joseph Breuer
>
> For validateRequired the following condition checks to see if the field is present. It then sets the validity to false.
> if (!jcv_isFieldPresent(field)) {
> fields[i++] = oRequired[x][1];
> isValid=false;
> }
> Supposedly validateRequired as well as all of the validate methods are not supposed to validate fields that are set as disabled. This method seems to categorize disabled fields with those that are null or are undefined.
> validateRequired should differentiate between the disabled fields and the not present fields.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org