I'm considering making a validation handler to integrate with the webform module. Please comment here if you would find that useful.

Please read the module description for an indication of what said plugin should be able to provide.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

darvanen created an issue. See original summary.

darvanen’s picture

Issue summary: View changes
alphex’s picture

voting for this...

I'd love to be able to easily list domains that can be refused in an email field on webform.

darvanen’s picture

@alphex a question: should it be configurable per-handler or would using the site-wide configuration be enough for your use-case?

Asking because I'm not sure how to support translations inside the webform handler.

alphex’s picture

I think ideally, it would be a setting for each form - as I can see some forms needing to be locked down by domain validation on a required email field...

where other forms, on the same site would allow any email to be validated in a required email field.

Kristen Pol made their first commit to this issue’s fork.

kristen pol’s picture

Whoops. Didn't mean to click that... browser was being sluggish. Sorry for the noise :)

joshua1234511 made their first commit to this issue’s fork.

joshua1234511’s picture

Added some basic functionality to get started with
Implemented
- Added the advanced_email_webform_validator_handler
- Implemented the configuration form
-- Includes Configurable "Select the email field/s to be validated" Predefined email field values obtained from the form it self.
-- Handler can be added only if email field exits in the form
-- Handler can be configured for webform, ignoring the global.

Pending
-- add the hook validator handler to validate on form submit
-- Pass global settings as default

Progress
Progress
Progress

darvanen’s picture

Amazing work, thank you! I love how much thought is going into this.

I had orignially envisaged the handler not even having form inputs for the validator settings if it was using the site defaults but passing the defaults through to the form elemetns could work too. Comes with pros and cons:

Pro: Webform settings won't be altered by changes to the site settings

Con: Webform settings won't be updated with changes to the site settings ;)

I can see use-cases for both.

Perhaps we could have a best-of-both-worlds approach? A checkbox to "override site defaults" which then displays the settings fields? That way if it is not checked, you just don't pass any config to the service when you run validate and it will use the auto-loaded site defaults.

Thoughts?

kristen pol’s picture

Status: Active » Needs work

Nice work... changing to needs work for the remaining items in #9 and the feedback in #10.

joshua1234511’s picture

Assigned: Unassigned » joshua1234511
StatusFileSize
new74.48 KB
new57.89 KB

Updated branch with
-- Pass global settings as default
Request from #10
Override setting added to use global values if no changes.
Commit: https://git.drupalcode.org/issue/advanced_email_validation-3262799/-/com...
Demo
Demo

Pending
-- add the hook validator handler to validate on form submit

joshua1234511’s picture

Assigned: joshua1234511 » Unassigned
Status: Needs work » Needs review
Issue tags: +undefined
StatusFileSize
new86.49 KB

Implemented the hook validator handler to validate on form submit
Webform handler can be configure for each email field separately or collectively.
Settings can be global or individual.
Error

kristen pol’s picture

Issue tags: -undefined

Removing tag.

Reviewed for formatting and comments/text and found some minor things.

Someone else should review to see if the code covers what is wanted.

darvanen’s picture

Status: Needs review » Needs work
StatusFileSize
new95.24 KB
new68.99 KB

This is fantastic! Thank you for the work that went into it so far.

I've tested out the validator and it works brilliantly with the default settings (again, thank you), but it seems the option to override has an issue. The values get saved into the handler and it seems the checkbox to turn on a rule is working, but not the error message override.

Here's the settings I put the on the handler:

And here's the result:

Otherwise this is looking pretty complete, I'll make sure to credit you on the project page when this is committed as it's a big piece of functionality.

joshua1234511’s picture

Fixed issues reported in #16

Testing
Testing
Testing
Testing

darvanen’s picture

Title: Webform validation handler? » Webform validation handler
Status: Needs review » Needs work
Issue tags: -Needs manual testing +Needs tests

Looks great @joshua1234511, just one more comment on the code then I reckon we're good to go. I've tagged this for automated test but I won't hold back committing the feature waiting on those, they can be a follow-up if they're not done by the time the feature is ready.

darvanen’s picture

Status: Needs work » Fixed

I'll make a follow-up for tests. Thanks everyone, I think this is going to be a really useful thing :)

darvanen’s picture

If anyone landing here would like to have a go at writing tests for this feature, please see #3274693: Write tests for webform validation handler

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.