Closed (fixed)
Project:
Webform Validation
Version:
6.x-1.0
Component:
Validation rules
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
19 Jan 2010 at 03:13 UTC
Updated:
3 Feb 2010 at 17:20 UTC
Jump to comment: Most recent file
Comments
Comment #1
gregarios commentedComment #2
gregarios commentedAttached is a patch to correct the behavior in the webform_validation.validators.inc file. The patch allows these built-in validators to ignore fields with no content in them:
Validating the presence of content in a field can be left to the Webforms module itself... so it is not needed in this module anyway.
This patch allows such things as a non-required Zip Code field to not have any value and still validate -- while the same field, if filled, will have to pass the validator's requirements.
Comment #3
gregarios commentedThe attached is a new patch which includes a new Email Validator option in the list of default validator rules. Please apply in a new release if you would. It includes the previous patch enhancements from comment #2 above as well. Use on version 6.x-1.0.
Comment #4
gregarios commentedTitle change... "fields required" is handled by the core Webforms module. There is no need to verify that the field is not empty, only that the data in it validates, if it exists.
Comment #5
svendecabooterThat makes sense gregarios.
I applied the code in #2 to the dev release.
With regards to the email validation function: I'm not sure if it's really needed.
If you add an 'email' form element to a webform, the webform core module already does validation (function _webform_validate_email in email.inc).
However this function uses the default Drupal valid_email_address(). I'm not sure how that compares to filter_var($val, FILTER_VALIDATE_EMAIL), and whether one or the other is better, so i'm putting this on hold for now.
If your suggested function would be a better way to validate email addresses, perhaps it would make more sense to try to get that implemented upstream (i.e. in the webform module or Drupal core).
Comment #6
svendecabooterComment #7
gregarios commentedI can understand that... I found that the Drupal built-in email validator didn't validate as well in testing. The
filter_var($val, FILTER_VALIDATE_EMAIL)seems more strict. Can it hurt? :-) (I've already begun using the patched module on my site, too. lol)The extra email validation helps when you want to place an email address in a 'hidden' field using PHP to gather it.
See this issue about the Core vs the filter_var: http://drupal.org/node/308138
They are talking about the Dev 8.x version of Drupal getting it... so they probably aren't interested in putting it into v6 for us. Yours would make it a choice for version 6 users.
Getting it into your module would be easier than getting it into core I believe. :-)
Thanks for getting the #2 patch in. Will you be making a version 1.1 release from the dev soon?