nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: validatorjs/validator.js
Pull request #1233 (2020-01-14 18:30:30)

Support CSS Colors Level 4 spec
The [CSS Color Module Level 4 Working Draft](https://drafts.csswg.org/css-color/#colorunits) now supports 4 or 8-digit hex colors (using the last bits for alpha transparency). 

It's already supported in [every major browser but IE](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Browser_compatibility) and will be supported in IE soon with their imminent switch to [Chromium](https://www.techcentral.ie/microsoft-to-begin-replacing-edge-with-its-chromium-based-browser-this-week/).

profnandaa: @acconrad -- thanks for the contrib! 🎉

Patch:
diff --git a/src/lib/isHexColor.js b/src/lib/isHexColor.js
index 01f9d0e..21a0375 100644
--- a/src/lib/isHexColor.js
+++ b/src/lib/isHexColor.js
@@ -1,6 +1,6 @@
 import assertString from './util/assertString';
 
-const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i;
+const hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i;
 
 export default function isHexColor(str) {
   assertString(str);


Test patch:
diff --git a/test/validators.js b/test/validators.js
index c2f2a2f..cf3f09d 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -2588,14 +2588,16 @@ describe('Validators', () => {
     test({
       validator: 'isHexColor',
       valid: [
+        '#ff0000ff',
         '#ff0034',
         '#CCCCCC',
+        '0f38',
         'fff',
         '#f00',
       ],
       invalid: [
         '#ff',
-        'fff0',
+        'fff0a',
         '#ff12FG',
       ],
     });
Repository: validatorjs/validator.js
Pull request #1265 (2020-03-04 21:31:01)

feat: Add Algeria Passport (DZ)
Add Algeria (DZ) RegEx passport code.

annymosse: hi @tux-tn , i didn't coz there's no need, after all it will just reuse it as any other similar patterns  like (US,Ukraine,...) ,however it's easy to do it (I will copy - past similar testers. "sahla barcha barcha :sweat_smile:")
tux-tn: @annymosse i know that the same pattern exists in other country codes but it will help to detect if someone else mistakenly edited DZ regex or isPassport validator and also to keep 100% code coverage in the project 😄 
annymosse: > @annymosse i know that the same pattern exists in other country codes but it will help to detect if someone else mistakenly edited DZ regex or isPassport validator and also to keep 100% code coverage in the project

You have a right , i forgot this kind of mistakes .
tux-tn: @annymosse fix the trailing space issue (check the latest pipeline) and it should be all good
annymosse: i thought there's no problem thank you @tux-tn for your mention and remind :+1: .
tux-tn: Thank you for your responsiveness!
@profnandaa Can you check this PR when you have time? 

Patch:
diff --git a/src/lib/isPassportNumber.js b/src/lib/isPassportNumber.js
index 304f72f..5d28573 100644
--- a/src/lib/isPassportNumber.js
+++ b/src/lib/isPassportNumber.js
@@ -18,6 +18,7 @@ const passportRegexByCountryCode = {
   CZ: /^\d{8}$/, // CZECH REPUBLIC
   DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/, // GERMANY
   DK: /^\d{9}$/, // DENMARK
+  DZ: /^\d{9}$/, // ALGERIA
   EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/, // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits
   ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/, // SPAIN
   FI: /^[A-Z]{2}\d{7}$/, // FINLAND


Test patch:
diff --git a/test/validators.js b/test/validators.js
index d87a188..9762d84 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -2010,6 +2010,23 @@ describe('Validators', () => {
       ],
     });
 
+    test({
+      validator: 'isPassportNumber',
+      args: ['DZ'],
+      valid: [
+        '855609385',
+        '154472412',
+        '197025599',
+      ],
+      invalid: [
+        'AS0123456',
+        'A012345678',
+        '0123456789',
+        '12345678',
+        '98KK54321',
+      ],
+    });
+
     test({
       validator: 'isPassportNumber',
       args: ['EE'],
Repository: validatorjs/validator.js
Pull request #1268 (2020-03-11 19:40:18)

fix(isIBAN): only strip spaces and hyphens before validating IBAN
It turns out the IBAN validation is not working correctly as commented here https://github.com/validatorjs/validator.js/issues/951#issuecomment-597792821

The following function in isIBAN.js seems buggy:

```
function hasValidIbanFormat(str) {
  // Strip white spaces and hyphens, keep only digits and A-Z latin alphabetic
  const strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase();
  const isoCountryCode = strippedStr.slice(0, 2).toUpperCase();

  return (isoCountryCode in ibanRegexThroughCountryCode) &&
      ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
}
```

We should not keep only digits and A-Z latin alphabetic, because any special char will be stripped away as well. We only want to **strip spaces and hyphens**.

Indeed we want the following IBANs to be **INVALID**:
- FR7630006000011234567890189@
- 'FR7630006000011234567890189😅
- FR763000600001123456!!🤨7890189@

This PR fix the issue

GoMino: @profnandaa I have just updated my pull request.

It wasn't clear to why the build artefacts was not added to `.gitignore` (https://github.com/validatorjs/validator.js/pull/1143#issuecomment-597831127).

I would really appreciate if you could publish a new version of the library once this pull request get merged as we are using this library inone of our project right now.

Thanks for you great work by the way!


Patch:
diff --git a/src/lib/isIBAN.js b/src/lib/isIBAN.js
index cb753ac..5b6da59 100644
--- a/src/lib/isIBAN.js
+++ b/src/lib/isIBAN.js
@@ -94,12 +94,12 @@ const ibanRegexThroughCountryCode = {
  * @return {boolean}
  */
 function hasValidIbanFormat(str) {
-  // Strip white spaces and hyphens, keep only digits and A-Z latin alphabetic
-  const strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase();
+  // Strip white spaces and hyphens
+  const strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase();
   const isoCountryCode = strippedStr.slice(0, 2).toUpperCase();
 
   return (isoCountryCode in ibanRegexThroughCountryCode) &&
-      ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
+    ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr);
 }
 
 /**


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 6be7c76..17e72f4 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -3825,6 +3825,9 @@ describe('Validators', () => {
       invalid: [
         'XX22YYY1234567890123',
         'FR14 2004 1010 0505 0001 3',
+        'FR7630006000011234567890189@',
+        'FR7630006000011234567890189😅',
+        'FR763000600001123456!!🤨7890189@',
       ],
     });
   });
Repository: validatorjs/validator.js
Pull request #1301 (2020-05-13 07:00:48)

feat(isMobilePhone): update zh-CN validation
For more details: https://www.chahaoba.com/手机号段

![image](https://user-images.githubusercontent.com/25809109/81781299-7efe9500-952a-11ea-91f9-10125f79ba22.png)




Patch:
diff --git a/.travis.yml b/.travis.yml
index 6121525..6833ce4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,7 +7,8 @@ node_js:
   - 10
   - 9
   - 8
+  - 6
 notifications:
   email: false
 after_script:
-  - npm install coveralls & coveralls
\ No newline at end of file
+  - npm install coveralls & coveralls
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index ec2a387..7eb4b80 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -93,7 +93,7 @@ const phones = {
   'tr-TR': /^(\+?90|0)?5\d{9}$/,
   'uk-UA': /^(\+?38|8)?0\d{9}$/,
   'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/,
-  'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[189])[0-9]{8}$/,
+  'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/,
   'zh-TW': /^(\+?886\-?|0)?9\d{8}$/,
 };
 /* eslint-enable max-len */


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 9db1232..ad8e4c8 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -5127,6 +5127,11 @@ describe('Validators', () => {
           '008618812341234',
           '+8619912341234',
           '+8619812341234',
+          '+8619712341234',
+          '+8619612341234',
+          '+8619512341234',
+          '+8619312341234',
+          '+8619212341234',
           '+8619112341234',
           '17269427292',
           '16565600001',
Repository: validatorjs/validator.js
Pull request #1313 (2020-05-26 09:07:29)

isPassportNumber -> Added indian passport

profnandaa: @parasg1999 -- never mind, we don't have locale listing for the validator, perhaps we need to add them, I'll merge for now.

Patch:
diff --git a/src/lib/isPassportNumber.js b/src/lib/isPassportNumber.js
index 5d28573..7dad94d 100644
--- a/src/lib/isPassportNumber.js
+++ b/src/lib/isPassportNumber.js
@@ -28,6 +28,7 @@ const passportRegexByCountryCode = {
   HR: /^\d{9}$/, // CROATIA
   HU: /^[A-Z]{2}(\d{6}|\d{7})$/, // HUNGARY
   IE: /^[A-Z0-9]{2}\d{7}$/, // IRELAND
+  IN: /^[A-Z]{1}-?\d{7}$/, // INDIA
   IS: /^(A)\d{7}$/, // ICELAND
   IT: /^[A-Z0-9]{2}\d{7}$/, // ITALY
   JP: /^[A-Z]{2}\d{7}$/, // JAPAN


Test patch:
diff --git a/test/validators.js b/test/validators.js
index db9bc39..6dd77f8 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -2156,6 +2156,20 @@ describe('Validators', () => {
       ],
     });
 
+    test({
+      validator: 'isPassportNumber',
+      args: ['IN'],
+      valid: [
+        'A-1234567',
+        'A1234567',
+        'X0019390',
+      ],
+      invalid: [
+        'AB-1234567',
+        '0123456789',
+      ],
+    });
+
     test({
       validator: 'isPassportNumber',
       args: ['IS'],
Repository: validatorjs/validator.js
Pull request #1338 (2020-05-31 11:38:07)

Fix Space Error in isSlug()
Issue #1287 

feat(isSlug): Fixed the problem in which isSlug() was also returning `true` for slugs with spaces for e.g. `not a-slug`.

I created a regex which will reject the slug while testing if it has spaces in the beginning, in the middle or at the end and has replaced my regex with the current one.


asp2809: Please have a look and tell me if there is anything that was left out while fixing it.
profnandaa: LGTM, thanks for your contribution and welcome to the project 🎉

Patch:
diff --git a/src/lib/isSlug.js b/src/lib/isSlug.js
index bb1b290..da01931 100644
--- a/src/lib/isSlug.js
+++ b/src/lib/isSlug.js
@@ -1,6 +1,6 @@
 import assertString from './util/assertString';
 
-let charsetRegex = /^[^-_](?!.*?[-_]{2,})([a-z0-9\\-]{1,}).*[^-_]$/;
+let charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/;
 
 export default function isSlug(str) {
   assertString(str);


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 0caf824..a842e71 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -8369,6 +8369,7 @@ describe('Validators', () => {
         'not-slug-',
         '_not-slug',
         'not-slug_',
+        'not slug',
       ],
     });
   });
Repository: validatorjs/validator.js
Pull request #1367 (2020-06-28 07:50:42)

update isarel postalcode regex
update the regex to check for valid postal codes in isarel
closes https://github.com/validatorjs/validator.js/issues/1365

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [x] Tests written (where applicable)



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


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 431924b..e1a491e 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -8238,6 +8238,35 @@ describe('Validators', () => {
           '891123',
         ],
       },
+      {
+        locale: 'IL',
+        valid: [
+          '10200',
+          '10292',
+          '10300',
+          '10329',
+          '3885500',
+          '4290500',
+          '4286000',
+          '7080000',
+        ],
+        invalid: [
+          '123',
+          '012345',
+          '011111',
+          '101123',
+          '291123',
+          '351123',
+          '541123',
+          '551123',
+          '651123',
+          '661123',
+          '861123',
+          '871123',
+          '881123',
+          '891123',
+        ],
+      },
       {
         locale: 'BG',
         valid: [
Repository: validatorjs/validator.js
Pull request #1370 (2020-07-02 12:15:39)

fixed spaninsh postal code and mobile number regex
changed new regex for spaninsh postal code and mobile number

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [x] Tests written (where applicable)


rubiin: @profnandaa this is the new PR

Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 7282be8..2362807 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -51,7 +51,7 @@ const phones = {
   'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/,
   'es-CR': /^(\+506)?[2-8]\d{7}$/,
   'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
-  'es-ES': /^(\+?34)?(6\d{1}|7[1234])\d{7}$/,
+  'es-ES': /^(\+?34)?[6|7]\d{8}$/,
   'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
   'es-PA': /^(\+?507)\d{7,8}$/,
   'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js
index 273d2f7..f9d81f6 100644
--- a/src/lib/isPostalCode.js
+++ b/src/lib/isPostalCode.js
@@ -20,7 +20,7 @@ const patterns = {
   DK: fourDigit,
   DZ: fiveDigit,
   EE: fiveDigit,
-  ES: fiveDigit,
+  ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/,
   FI: fiveDigit,
   FR: /^\d{2}\s?\d{3}$/,
   GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index e1a491e..f84c73d 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -5945,10 +5945,10 @@ describe('Validators', () => {
           '65478932',
           '+346547893210',
           '6547893210',
-          '+34704789321',
-          '704789321',
-          '+34754789321',
-          '754789321',
+          '+3470478932',
+          '7047893210',
+          '+34854789321',
+          '7547893219',
         ],
       },
       {
@@ -8142,6 +8142,22 @@ describe('Validators', () => {
           'V5K 0A1',
         ],
       },
+      {
+        locale: 'ES',
+        valid: [
+          '01001',
+          '52999',
+          '27880',
+        ],
+        invalid: [
+          '123',
+          '1234',
+          '53000',
+          '052999',
+          '0123',
+          'abcde',
+        ],
+      },
       {
         locale: 'JP',
         valid: [
Repository: validatorjs/validator.js
Pull request #1391 (2020-07-25 05:21:03)

bug(isMobilePhone): update regex for de-DE
<!--
Add a descriptive title textbox above, e.g.
feat(validatorName): brief title of what has been done
-->

I loosened the regex for de-DE to support the unhandled value given in the issue.
The changes prompts some of the invalid values to pass, but I added additional tests to backup the change.

## Checklist

- [] PR contains only changes related; no stray files, etc.
- [] README updated (where applicable)
- [] Tests written (where applicable)



Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 2362807..dbd95c9 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -20,7 +20,7 @@ const phones = {
   '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}$/,
+  'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/,
   'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
   'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/,
   'el-GR': /^(\+?30|0)?(69\d{8})$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 81ad1d4..e64abb7 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -5155,6 +5155,7 @@ describe('Validators', () => {
         valid: [
           '+49015123456789',
           '+4915123456789',
+          '+4930405044550',
           '015123456789',
           '15123456789',
           '15623456789',
@@ -5165,15 +5166,16 @@ describe('Validators', () => {
           '1631234567',
           '1701234567',
           '17612345678',
-        ],
-        invalid: [
           '15345678910',
           '15412345678',
+        ],
+        invalid: [
+          '34412345678',
+          '14412345678',
           '16212345678',
           '1761234567',
           '16412345678',
           '17012345678',
-          '12345678910',
           '+4912345678910',
         ],
       },
Repository: validatorjs/validator.js
Pull request #1394 (2020-07-27 03:16:24)

fix(isIBAN): add support for EG and SV
<!--
Add a descriptive title textbox above, e.g.
feat(validatorName): brief title of what has been done
-->

I added regex for EG and SV and added test for each.
- EG800002000156789012345180002
- SV43ACAT00000000000000123123

Some of the IBANs provided in the issue seems to be working as expected:
- SC52BAHL01031234567890123456USD
- LC14BOSL123456789012345678901234
- MT31MALT01100000000000000000123

... so I added them in the tests to prove the validity.


## Checklist

- [ ] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [ ] Tests written (where applicable)



Patch:
diff --git a/src/lib/isIBAN.js b/src/lib/isIBAN.js
index 3652dce..77050f1 100644
--- a/src/lib/isIBAN.js
+++ b/src/lib/isIBAN.js
@@ -25,6 +25,7 @@ const ibanRegexThroughCountryCode = {
   DK: /^(DK[0-9]{2})\d{14}$/,
   DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/,
   EE: /^(EE[0-9]{2})\d{16}$/,
+  EG: /^(EG[0-9]{2})\d{25}$/,
   ES: /^(ES[0-9]{2})\d{20}$/,
   FI: /^(FI[0-9]{2})\d{14}$/,
   FO: /^(FO[0-9]{2})\d{14}$/,
@@ -74,6 +75,7 @@ const ibanRegexThroughCountryCode = {
   SI: /^(SI[0-9]{2})\d{15}$/,
   SK: /^(SK[0-9]{2})\d{20}$/,
   SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/,
+  SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/,
   TL: /^(TL[0-9]{2})\d{19}$/,
   TN: /^(TN[0-9]{2})\d{20}$/,
   TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index e64abb7..93ce2d2 100755
--- a/test/validators.js
+++ b/test/validators.js
@@ -3954,6 +3954,11 @@ describe('Validators', () => {
     test({
       validator: 'isIBAN',
       valid: [
+        'SC52BAHL01031234567890123456USD',
+        'LC14BOSL123456789012345678901234',
+        'MT31MALT01100000000000000000123',
+        'SV43ACAT00000000000000123123',
+        'EG800002000156789012345180002',
         'BE71 0961 2345 6769',
         'FR76 3000 6000 0112 3456 7890 189',
         'DE91 1000 0000 0123 4567 89',