8000 mobile number for Russia Federation by jehadja · Pull Request #2207 · jquery-validation/jquery-validation · GitHub
[go: up one dir, main page]

Skip to content

mobile number for Russia Federation < 8000 span class="f1-light color-fg-muted">#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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 6, 2018
Merged

Conversation

jehadja
Copy link
Contributor
@jehadja jehadja commented Sep 3, 2018

Description

Thank you!

@Arkni
Copy link
Member
Arkni commented Sep 30, 2018

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

Copy link
Member
@Arkni Arkni 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 from mobileUK test:

QUnit.test( "mobileUK", function( assert ) {
var method = 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 variable phoneNumber 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 use regex.test instead of string.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
@Arkni Arkni 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 free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0