Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added support for custom email patterns, provided via options.emailRegex. #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

staabm
Copy link
Member

@staabm staabm commented Jul 10, 2015

Uses the current email regex per default to keep BC.

@staabm staabm force-pushed the remail branch 6 times, most recently from 5497099 to b83cd1b Compare July 10, 2015 08:37
@jzaefferer
Copy link
Collaborator

I'm okay with making the email validation configurable, but I really want to avoid adding more options. Partly because there are too many already, partly because this would tie in the method even more into the core.

To take a step back, why do you need this as an option? Could you override the email method as needed? Or use a custom email method when you need to the default on the same page?

@staabm
Copy link
Member Author

staabm commented Jul 10, 2015

To take a step back, why do you need this as an option? Could you override the email method as needed? Or use a custom email method when you need to the default on the same page?

I could of course use a separate email validation method. IMO email validation will only be different in the email format and per definition will not have other differences, so I decided to go this road.

In case email method validation itself would be a separate plugin, how would I define options for it?
Maybe we can find a way which later on will be BC with what we introduce now.

Per se, I would love to reduce the jquery-validation core to less lines and have a built which only contains the rules I really need for a certain app.

Pass it via options.emailRegex.
Defaults to the W3C defined pattern for BC.

Fix Test CS.
@staabm
Copy link
Member Author

staabm commented Jul 10, 2015

As you already know, email pattern issues are the most reported errors in this tracker, therefore solving the issue using a config param is a must have for a lot of our users. (I am not saying it has to be a option passed to the validator).

Is separating the core from the actual methods a step which requires a BC break or do you plan to solve it in a BC compatible way?

@staabm
Copy link
Member Author

staabm commented Jul 15, 2015

@jzaefferer what do you think, how to proceed?

@staabm
Copy link
Member Author

staabm commented Jul 16, 2015

I just tried the other way you proposed.

In case we promote the $.validator.methods.<myRule> properties to be part of the public api, I could override the native-email method with my custom regex without providing another option.

example:

// setup the validation
// ...
// place my override
$.validator.methods.email = function( value, element ) { 
  return this.optional( element ) || /whatEverRegexILike/.test( value ); 
}

@jzaefferer wdyt?

@jzaefferer
Copy link
Collaborator

That looks good to me.

@staabm staabm closed this Jul 21, 2015
@staabm
Copy link
Member Author

staabm commented Jul 21, 2015

will open a doc PR then, thanks.

@staabm
Copy link
Member Author

staabm commented Jul 21, 2015

@staabm staabm deleted the remail branch July 21, 2015 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants