nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: preactjs/preact-render-to-string
Pull request #391 (2024-08-28 23:04:16)

fix: allow any stringified value in class + className
Seems fine to merge, but then again this seems cursed and I'm worried that this list will get longer. For now it seems fine though.

Fixes https://github.com/preactjs/preact-render-to-string/issues/390


Patch:
diff --git a/.changeset/metal-bottles-play.md b/.changeset/metal-bottles-play.md
new file mode 100644
index 0000000..f44ccd5
--- /dev/null
+++ b/.changeset/metal-bottles-play.md
@@ -0,0 +1,5 @@
+---
+'preact-render-to-string': patch
+---
+
+Allow any value for `class` + `className` as long as it's stringified to match browser behavior.
diff --git a/src/index.js b/src/index.js
index 5362a9c..1977171 100644
--- a/src/index.js
+++ b/src/index.js
@@ -543,7 +543,9 @@ function _renderToString(
 	for (let name in props) {
 		let v = props[name];
 
-		if (typeof v == 'function') continue;
+		if (typeof v == 'function' && name !== 'class' && name !== 'className') {
+			continue;
+		}
 
 		switch (name) {
 			case 'children':


Test patch:
diff --git a/test/render.test.jsx b/test/render.test.jsx
index 39521cc..ba8e028 100644
--- a/test/render.test.jsx
+++ b/test/render.test.jsx
@@ -1678,6 +1678,18 @@ describe('render', () => {
 				}
 			}
 		});
+
+		// https://github.com/preactjs/preact-render-to-string/issues/390
+		// The DOM API casts any value to a string here.
+		it('should cast "className" and "class" value to string', () => {
+			const proxy = new Proxy(() => {}, {
+				get() {
+					return () => 'foo';
+				}
+			});
+			let rendered = render(<div className={proxy} />);
+			expect(rendered).to.equal(`<div class="foo"></div>`);
+		});
 	});
 
 	describe('precompiled JSX', () => {
Repository: cypress-io/eslint-plugin-cypress
Pull request #9 (2018-11-04 11:47:47)

Fix for #8


Patch:
diff --git a/lib/rules/no-assigning-return-values.js b/lib/rules/no-assigning-return-values.js
index 05b9a2d..f35570f 100644
--- a/lib/rules/no-assigning-return-values.js
+++ b/lib/rules/no-assigning-return-values.js
@@ -35,6 +35,9 @@ function isCypressCommandDeclaration(declarator) {
   if (!declarator.init.callee) { return; }
 
   let object = declarator.init.callee.object;
+
+  if (!object)                 { return; }
+
   while (object.callee) {
     object = object.callee.object;
   }


Test patch:
diff --git a/tests/lib/rules/no-assigning-return-values.js b/tests/lib/rules/no-assigning-return-values.js
index 427c3b7..7aab85c 100644
--- a/tests/lib/rules/no-assigning-return-values.js
+++ b/tests/lib/rules/no-assigning-return-values.js
@@ -13,6 +13,7 @@ ruleTester.run('no-assigning-return-values', rule, {
     { code: 'var foo = true;', parserOptions },
     { code: 'let foo = true;', parserOptions },
     { code: 'const foo = true;', parserOptions },
+    { code: 'const foo = bar();', parserOptions },
     { code: 'cy.get("foo");', parserOptions },
     { code: 'cy.contains("foo").click();', parserOptions }
   ],
Repository: cypress-io/eslint-plugin-cypress
Pull request #27 (2019-08-01 13:41:25)

Avoid mutating eslint browser environment
Currently the 'cypress/globals' env globals key is made into a copy
of the 'browser' env and changes its contents. Instead, make it a
distinct object.

Add test case that fails if the globals are tampered with on import.

Fixes cypress-io/eslint-plugin-cypress#26


Patch:
diff --git a/index.js b/index.js
index 3c433cb..044c699 100644
--- a/index.js
+++ b/index.js
@@ -11,13 +11,13 @@ module.exports = {
   },
   environments: {
     globals: {
-      globals: Object.assign(globals.browser, globals.mocha, {
+      globals: Object.assign({
         cy: false,
         Cypress: false,
         expect: false,
         assert: false,
         chai: false,
-      }),
+      }, globals.browser, globals.mocha),
       parserOptions: {
         ecmaVersion: 2019,
         sourceType: 'module',


Test patch:
diff --git a/tests/config.js b/tests/config.js
new file mode 100644
index 0000000..2bc9b2c
--- /dev/null
+++ b/tests/config.js
@@ -0,0 +1,25 @@
+'use strict'
+
+const globals = require('globals')
+const config = require('../index.js')
+
+describe('environments globals', () => {
+  const env = config.environments.globals
+
+  it('should not mutate globals', () => {
+    expect(globals.browser).not.toHaveProperty('cy')
+    expect(globals.mocha).not.toHaveProperty('cy')
+  });
+
+  it('should include other globals', () => {
+    expect(env.globals).toEqual(expect.objectContaining(globals.browser))
+    expect(env.globals).toEqual(expect.objectContaining(globals.mocha))
+  });
+
+  it('should include cypress globals', () => {
+    expect(env.globals).toEqual(expect.objectContaining({
+      cy: false,
+      Cypress: false,
+    }))
+  });
+})
Repository: cypress-io/eslint-plugin-cypress
Pull request #34 (2019-11-28 00:13:08)

Added handling for when the wait method is given an Identifier which has a number value
This is to handle cases where we have : 

const SLEEP = 500;

cy.wait(SLEEP)

This is still an unnecessary wait and should not be used.


Patch:
diff --git a/lib/rules/no-unnecessary-waiting.js b/lib/rules/no-unnecessary-waiting.js
index 3bac062..405f1f8 100644
--- a/lib/rules/no-unnecessary-waiting.js
+++ b/lib/rules/no-unnecessary-waiting.js
@@ -21,8 +21,12 @@ module.exports = {
   create (context) {
     return {
       CallExpression (node) {
-        if (isCallingCyWait(node) && isNumberArgument(node)) {
-          context.report({ node, messageId: 'unexpected' })
+        if (isCallingCyWait(node)) {
+          const scope = context.getScope()
+
+          if (isIdentifierNumberConstArgument(node, scope) || isNumberArgument(node)) {
+            context.report({ node, messageId: 'unexpected' })
+          }
         }
       },
     }
@@ -42,3 +46,14 @@ function isNumberArgument (node) {
          node.arguments[0].type === 'Literal' &&
          typeof (node.arguments[0].value) === 'number'
 }
+
+function isIdentifierNumberConstArgument (node, scope) {
+  if (node.arguments[0].type !== 'Identifier') {
+    return false
+  }
+
+  const resolvedIdentifier = scope.resolve(node.arguments[0]).resolved
+  const IdentifierValue = resolvedIdentifier.defs[0].node.init.value
+
+  return typeof IdentifierValue === 'number'
+}


Test patch:
diff --git a/tests/lib/rules/no-unnecessary-waiting.js b/tests/lib/rules/no-unnecessary-waiting.js
index 5532f71..50d1bca 100644
--- a/tests/lib/rules/no-unnecessary-waiting.js
+++ b/tests/lib/rules/no-unnecessary-waiting.js
@@ -18,11 +18,14 @@ ruleTester.run('no-unnecessary-waiting', rule, {
     { code: 'cy.clock(5000)', parserOptions },
     { code: 'cy.scrollTo(0, 10)', parserOptions },
     { code: 'cy.tick(500)', parserOptions },
+
+    { code: 'const someRequest="@someRequest"; cy.wait(someRequest)', parserOptions, errors },
   ],
 
   invalid: [
     { code: 'cy.wait(0)', parserOptions, errors },
     { code: 'cy.wait(100)', parserOptions, errors },
     { code: 'cy.wait(5000)', parserOptions, errors },
+    { code: 'const someNumber=500; cy.wait(someNumber)', parserOptions, errors },
   ],
 })
Repository: cypress-io/eslint-plugin-cypress
Pull request #48 (2020-02-18 04:19:17)

fix: require data selectors support template literal
Closes https://github.com/cypress-io/eslint-plugin-cypress/issues/37

Check for nodeType to be `TemplateLiteral` and quasis cooked value to start with `[data-` 


Patch:
diff --git a/lib/rules/require-data-selectors.js b/lib/rules/require-data-selectors.js
index b8d5203..f3f76af 100644
--- a/lib/rules/require-data-selectors.js
+++ b/lib/rules/require-data-selectors.js
@@ -39,7 +39,8 @@ function isCallingCyGet (node) {
 
 function isDataArgument (node) {
   return node.arguments.length > 0 &&
-  node.arguments[0].type === 'Literal' &&
-  String(node.arguments[0].value).startsWith('[data-')
-
+    (
+      (node.arguments[0].type === 'Literal' && String(node.arguments[0].value).startsWith('[data-')) ||
+      (node.arguments[0].type === 'TemplateLiteral' && String(node.arguments[0].quasis[0].value.cooked).startsWith('[data-'))
+    )
 }


Test patch:
diff --git a/tests/lib/rules/require-data-selectors.js b/tests/lib/rules/require-data-selectors.js
index af123dc..92036bb 100644
--- a/tests/lib/rules/require-data-selectors.js
+++ b/tests/lib/rules/require-data-selectors.js
@@ -15,6 +15,7 @@ ruleTester.run('require-data-selectors', rule, {
     { code: 'cy.clock(5000)', parserOptions },
     { code: 'cy.scrollTo(0, 10)', parserOptions },
     { code: 'cy.tick(500)', parserOptions },
+    { code: 'cy.get(\`[data-cy=${1}]\`)', parserOptions },
   ],
 
   invalid: [
@@ -23,5 +24,6 @@ ruleTester.run('require-data-selectors', rule, {
     { code: 'cy.get(".btn-large").click()', parserOptions, errors },
     { code: 'cy.get(".btn-.large").click()', parserOptions, errors },
     { code: 'cy.get(".a")', parserOptions, errors },
+    { code: 'cy.get(\`[daedta-cy=${1}]\`)', parserOptions, errors },
   ],
 })
Repository: cypress-io/eslint-plugin-cypress
Pull request #109 (2022-09-07 09:05:56)

Handle ImportBindings in `no-unnecessary-waiting` rule
This PR adds proper handling for ImportBindings in `no-unnecessary-waiting` rule to prevent reporting codes like this:

```js
// We don't know if WAIT is a number or alias '@someRequest'
import { WAIT } from './constnats'

cy.wait(WAIT)
```

It's similar to the existing case with function arguments where we cannot see the type of the argument. Similarly, we cannot know the type of import binding.

```js
  // function wait (amount) { cy.wait(amount) }
  // we can't know the type of value, so don't fail
  if (!param || param.type !== 'AssignmentPattern') return false
```

Resolves https://github.com/cypress-io/eslint-plugin-cypress/issues/43


Patch:
diff --git a/lib/rules/no-unnecessary-waiting.js b/lib/rules/no-unnecessary-waiting.js
index 8d206d7..53a8606 100644
--- a/lib/rules/no-unnecessary-waiting.js
+++ b/lib/rules/no-unnecessary-waiting.js
@@ -69,6 +69,11 @@ function isIdentifierNumberConstArgument (node, scope) {
     return typeof definition.node.init.value === 'number'
   }
 
+  // import { WAIT } from './constants'
+  // cy.wait(WAIT)
+  // we don't know if WAIT is a number or alias '@someRequest', so don't fail
+  if (definition.type === 'ImportBinding') return false
+
   const param = definition.node.params[definition.index]
 
   // function wait (amount) { cy.wait(amount) }


Test patch:
diff --git a/tests/lib/rules/no-unnecessary-waiting.js b/tests/lib/rules/no-unnecessary-waiting.js
index da43606..a788b2b 100644
--- a/tests/lib/rules/no-unnecessary-waiting.js
+++ b/tests/lib/rules/no-unnecessary-waiting.js
@@ -6,7 +6,7 @@ const RuleTester = require('eslint').RuleTester
 const ruleTester = new RuleTester()
 
 const errors = [{ messageId: 'unexpected' }]
-const parserOptions = { ecmaVersion: 6 }
+const parserOptions = { ecmaVersion: 6, sourceType: 'module' }
 
 ruleTester.run('no-unnecessary-waiting', rule, {
   valid: [
@@ -27,6 +27,11 @@ ruleTester.run('no-unnecessary-waiting', rule, {
     { code: 'function customWait (ms) { cy.wait(ms) }', parserOptions, errors },
     { code: 'const customWait = (ms) => { cy.wait(ms) }', parserOptions, errors },
 
+    { code: 'import BAR_BAZ from "bar-baz"; cy.wait(BAR_BAZ)', parserOptions },
+    { code: 'import { FOO_BAR } from "foo-bar"; cy.wait(FOO_BAR)', parserOptions },
+    { code: 'import * as wildcard from "wildcard"; cy.wait(wildcard.value)', parserOptions },
+    { code: 'import { NAME as OTHER_NAME } from "rename"; cy.wait(OTHER_NAME)', parserOptions },
+
     // disable the eslint rule
     {
       code: `
Repository: validatorjs/validator.js
Pull request #1073 (2019-07-28 14:50:24)

fix Japanese mobile phone number
Seems `isMobile` with `ja-JP` is wrong. (My mobile number does not pass😢)
This PR is to fix `isMoble` with ja-JP.

Basically, Japanese mobile phone number is:
090 or 080, 070 prefix plus 4-digits numbers * 2, like 090-xxxx-xxxx

Also, 060 prefix will be available due to about depleted of 090, 080, 070.
Here is the announcement from gov (in Japanese).
http://www.soumu.go.jp/menu_news/s-news/01kiban06_02000058.html


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 39eca2c..2269437 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -58,7 +58,7 @@ const phones = {
   'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
   'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
   'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
-  'ja-JP': /^(\+?81|0)[789]0[ \-]?[1-9]\d{2}[ \-]?\d{5}$/,
+  'ja-JP': /^(\+?81|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
   'kk-KZ': /^(\+?7|8)?7\d{9}$/,
   'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
   'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 1399c8d..69d8da7 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -4779,9 +4779,12 @@ describe('Validators', () => {
       {
         locale: 'ja-JP',
         valid: [
-          '09012345688',
-          '090 123 45678',
-          '+8190-123-45678',
+          '09012345678',
+          '08012345678',
+          '07012345678',
+          '06012345678',
+          '090 1234 5678',
+          '+8190-1234-5678',
         ],
         invalid: [
           '12345',
@@ -4794,7 +4797,6 @@ describe('Validators', () => {
           '03_1234_5689',
           '0312345678',
           '0721234567',
-          '08002345678',
           '06 1234 5678',
           '072 123 4567',
           '0729 12 3456',
Repository: validatorjs/validator.js
Pull request #1132 (2019-10-06 11:23:30)

fix: isMobilePhone bn-BD add Banglalink (014)
Add new Banglalink `014` series in `isMobilePhone` for `bn-BD`

Link: https://www.banglalink.net/en/about-us/media/press-release/banglalink-launches-new-number-series-014


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index fe780cd..cc4c4f7 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -14,7 +14,7 @@ const phones = {
   'ar-TN': /^(\+?216)?[2459]\d{7}$/,
   'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/,
   'bg-BG': /^(\+?359|0)?8[789]\d{7}$/,
-  'bn-BD': /^(\+?880|0)1[1356789][0-9]{8}$/,
+  'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/,
   'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/,
   'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/,
   'de-DE': /^(\+49)?0?1(5[0-25-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 13368fb..09715fb 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -3862,13 +3862,13 @@ describe('Validators', () => {
           '01717112029',
           '8801898765432',
           '+8801312345678',
+          '01494676946',
         ],
         invalid: [
           '',
           '0174626346',
           '017943563469',
           '18001234567',
-          '01494676946',
           '0131234567',
         ],
       },
Repository: validatorjs/validator.js
Pull request #1152 (2019-10-12 11:54:38)

postal code validation fix for locale IN
Issue fix for https://github.com/validatorjs/validator.js/issues/1151

preethamvishy: This is a good catch! 
I got curious and looked up valid Indian pin codes and I found this: https://www.thebetterindia.com/70401/decoding-the-indian-pincode/. Do we want validation for first 2 digits of the pin code? For example, 35XXXX and 86XXXX are invalid too, apparently.
adityaraval: @preethamvishy according to this https://www.thebetterindia.com/70401/decoding-the-indian-pincode/

I have updated the regex. Now it will not validate the postal codes starts with (10,29,35,54,55,65,66,86,87,88,89)

Patch:
diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js
index 296d590..4176d5a 100644
--- a/src/lib/isPostalCode.js
+++ b/src/lib/isPostalCode.js
@@ -30,7 +30,7 @@ const patterns = {
   ID: fiveDigit,
   IE: /^[A-z]\d[\d|w]\s\w{4}$/i,
   IL: fiveDigit,
-  IN: sixDigit,
+  IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/,
   IS: threeDigit,
   IT: fiveDigit,
   JP: /^\d{3}\-\d{4}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 09715fb..0efbd4a 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -6743,6 +6743,29 @@ describe('Validators', () => {
           'A65T F12',
         ],
       },
+      {
+        locale: 'IN',
+        valid: [
+          '364240',
+          '360005',
+        ],
+        invalid: [
+          '123',
+          '012345',
+          '011111',
+          '101123',
+          '291123',
+          '351123',
+          '541123',
+          '551123',
+          '651123',
+          '661123',
+          '861123',
+          '871123',
+          '881123',
+          '891123',
+        ],
+      },
       {
         locale: 'BG',
         valid: [
Repository: validatorjs/validator.js
Pull request #1166 (2019-10-18 12:12:22)

Fixed isMobile (ja-JP)
Modified `ja-JP` check to do the following:
* Allow space or dash between the +81 country code and the local area code
* In the case that +81 is included, allow leading zero in parenthesis of local area code as often done on Japanese business cards i.e. `+81 (0)90 1234 5678`

Previous test cases still pass. Added additional test cases to test the modifications.


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index cc4c4f7..779bf53 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -59,7 +59,7 @@ const phones = {
   'hu-HU': /^(\+?36)(20|30|70)\d{7}$/,
   'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/,
   'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
-  'ja-JP': /^(\+?81|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
+  'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
   'kk-KZ': /^(\+?7|8)?7\d{9}$/,
   'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
   'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index aee86d7..911daa6 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -4929,6 +4929,10 @@ describe('Validators', () => {
           '06012345678',
           '090 1234 5678',
           '+8190-1234-5678',
+          '+81 (0)90-1234-5678',
+          '+819012345678',
+          '+81-(0)90-1234-5678',
+          '+81 90 1234 5678',
         ],
         invalid: [
           '12345',
@@ -4949,6 +4953,10 @@ describe('Validators', () => {
           '03-1234-5678',
           '+81312345678',
           '+816-1234-5678',
+          '+81 090 1234 5678',
+          '+8109012345678',
+          '+81-090-1234-5678',
+          '90 1234 5678',
         ],
       },
       {
Repository: validatorjs/validator.js
Pull request #1213 (2019-12-09 05:13:51)

allow spaces in Hong Kong and Macau phone numbers
1) Allow spaces in Hong Kong and Macau phone numbers, because in the overwhelming majority of cases the numbers are written like: 

+853 6123 4567
+852 9123 4567

Reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Hong_Kong

2) Disallow phone numbers starting from 2 and 8 in Macau, because they are not mobile phones (they are landlines).

Reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Macau


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 38e8adc..154f6ea 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -24,8 +24,8 @@ const phones = {
   'en-GB': /^(\+?44|0)7\d{9}$/,
   'en-GG': /^(\+?44|0)1481\d{6}$/,
   'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/,
-  'en-HK': /^(\+?852\-?)?[456789]\d{3}\-?\d{4}$/,
-  'en-MO': /^(\+?853\-?)?[268]\d{3}\-?\d{4}$/,
+  'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/,
+  'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/,
   'en-IE': /^(\+?353|0)8[356789]\d{7}$/,
   'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
   'en-KE': /^(\+?254|0)(7|1)\d{8}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index f704bb9..5721212 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -4193,6 +4193,8 @@ describe('Validators', () => {
           '+85291234567',
           '+852-91234567',
           '+852-9123-4567',
+          '+852 9123 4567',
+          '9123 4567',
           '852-91234567',
         ],
         invalid: [
@@ -4209,6 +4211,8 @@ describe('Validators', () => {
           '+85361234567',
           '+853-61234567',
           '+853-6123-4567',
+          '+853 6123 4567',
+          '6123 4567',
           '853-61234567',
         ],
         invalid: [
@@ -4216,8 +4220,11 @@ describe('Validators', () => {
           '12345678',
           '612345678',
           '+853-12345678',
+          '+853-22345678',
+          '+853-82345678',
           '+853-612345678',
           '+853-1234-5678',
+          '+853 1234 5678',
           '+853-6123-45678',
         ],
       },
Repository: validatorjs/validator.js
Pull request #1217 (2019-12-16 11:25:46)

Add support for armenia phone
Resolves: #1215 
Resolves the above-mentioned issue but with a different kind of regex (not the one stated in the issue). That regex was very general. To know more about the format of Armenia phone, view this [link](http://www.atb.am/en/tourist/phonecodes/).

The format is:
 - +374 or 0 followed by 10 (Yerevan city code) plus 6 more digits
 - +374 or 0 followed by any digit starts with 2 - 4 plus 7 more digits.
 -  +374 or 0 followed by digits starts with 9 or 7 (Mobile carriers) plus 7 more digits.

Hence, the regex is `/^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/`.


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 154f6ea..a8fe5df 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -2,6 +2,7 @@ import assertString from './util/assertString';
 
 /* eslint-disable max-len */
 const phones = {
+  'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/,
   'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/,
   'ar-BH': /^(\+?973)?(3|6)\d{7}$/,
   'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 5721212..8a9e775 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -3738,6 +3738,25 @@ describe('Validators', () => {
 
   it('should validate mobile phone number', () => {
     let fixtures = [
+      {
+        locale: 'am-AM',
+        valid: [
+          '+37410324123',
+          '+37422298765',
+          '+37431276521',
+          '022698763',
+          '37491987654',
+          '+37494567890',
+        ],
+        invalid: [
+          '12345',
+          '+37411498855',
+          '+37411498123',
+          '05614988556',
+          '',
+          '37456789000',
+        ],
+      },
       {
         locale: 'ar-AE',
         valid: [