Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

mobile number for Russia Federation#2207

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Arkni merged 6 commits intojquery-validation:masterfromjehadja:master
Nov 6, 2018

Conversation

jehadja
Copy link
Contributor

Description

Thank you!

@Arkni
Copy link
Member

Thanks for your contribution! I'll triage and take a look at it as soon as possible!

Copy link
Member

@ArkniArkni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks for your contribution.

Overall, it looks good. Only 2 changes are needed + a test case to be added and we are good to go.
For the test case, you can inspire frommobileUK test:

QUnit.test("mobileUK",function(assert){
varmethod=methodTest("mobileUK");
assert.ok(method("07134234323"),"Valid UK Mobile Number");
assert.ok(method("07334234323"),"Valid UK Mobile Number");
assert.ok(method("07624234323"),"Valid UK Mobile Number");
assert.ok(method("07734234323"),"Valid UK Mobile Number");
assert.ok(method("+447134234323"),"Valid UK Mobile Number");
assert.ok(method("+447334234323"),"Valid UK Mobile Number");
assert.ok(method("+447624234323"),"Valid UK Mobile Number");
assert.ok(method("+447734234323"),"Valid UK Mobile Number");
assert.ok(!method("07034234323"),"Invalid UK Mobile Number");
assert.ok(!method("0753423432"),"Invalid UK Mobile Number");
assert.ok(!method("07604234323"),"Invalid UK Mobile Number");
assert.ok(!method("077342343234"),"Invalid UK Mobile Number");
assert.ok(!method("044342343234"),"Invalid UK Mobile Number");
assert.ok(!method("+44753423432"),"Invalid UK Mobile Number");
assert.ok(!method("+447604234323"),"Invalid UK Mobile Number");
assert.ok(!method("+4477342343234"),"Invalid UK Mobile Number");
assert.ok(!method("+4444342343234"),"Invalid UK Mobile Number");
});

You can add your tests to the same file.

Thanks!

@@ -0,0 +1,6 @@
/* mobile number for Russia Fedaration */
$.validator.addMethod( "mobileRU", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please create a new variablephoneNumber or something else and assign the result to it.

$.validator.addMethod( "mobileRU", function( phone_number, element ) {
phone_number = phone_number.replace( /\(|\)|\s+|-/g, "" );
return this.optional( element ) || phone_number.length > 9 &&
phone_number.match( /^((\+7|7|8)+([0-9]){10})$/ );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Please useregex.test instead ofstring.match. We only need to know whether the string matches the regex or not.
phone_number.match( /^((\+7|7|8)+([0-9]){10})$/ ) =>/^((\+7|7|8)+([0-9]){10})$/.test( phone_number )

Copy link
Member

@ArkniArkni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM 👍

Thanks a lot for working on this :)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ArkniArkniArkni approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@jehadja@Arkni

[8]ページ先頭

©2009-2025 Movatter.jp