nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: validatorjs/validator.js
Pull request #1939 (2022-03-13 06:15:27)

fix(isFQDN): allow_numeric_tld option didn't work
According to the mentioned on this comment https://github.com/validatorjs/validator.js/issues/1923#issuecomment-1029809187

> Example: `abc.efg.g1h.` will always fail, current `options` don't provide this use case, but is valid
> 
> ```js
> validator.isFQDN('abc.efg.g1h.', 
>   { allow_trailing_dot: true, allow_underscores: true, allow_numeric_tld: true}); // false but should be true
> ```

the option allow_numeric_tld didn't work as supposed to do, this PR tries to fix that.

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)



Patch:
diff --git a/src/lib/isFQDN.js b/src/lib/isFQDN.js
index 4a04cf3..884d1dd 100644
--- a/src/lib/isFQDN.js
+++ b/src/lib/isFQDN.js
@@ -32,7 +32,7 @@ export default function isFQDN(str, options) {
       return false;
     }
 
-    if (!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
+    if (!options.allow_numeric_tld && !/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) {
       return false;
     }
 


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 61ffe09..dcac6ec 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -1291,7 +1291,18 @@ describe('Validators', () => {
       ],
     });
   });
-
+  it('should validate FQDN with required allow_trailing_dot, allow_underscores and allow_numeric_tld options', () => {
+    test({
+      validator: 'isFQDN',
+      args: [
+        { allow_trailing_dot: true, allow_underscores: true, allow_numeric_tld: true },
+      ],
+      valid: [
+        'abc.efg.g1h.',
+        'as1s.sad3s.ssa2d.',
+      ],
+    });
+  });
   it('should validate alpha strings', () => {
     test({
       validator: 'isAlpha',
Repository: validatorjs/validator.js
Pull request #1946 (2022-03-28 07:07:27)

fix(isMobilePhone): Change fi-FI mobile phone number regexp to support 050xxxx numbers
<!--
Add a descriptive title textbox above, e.g.
feat(validatorName): brief title of what has been done
-->

0501234 should be a valid mobile phone number in Finland. 
<!--- briefly describe what you have done in this PR --->

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)



Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 575415e..68b7508 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -80,7 +80,7 @@ const phones = {
   'es-VE': /^(\+?58)?(2|4)\d{9}$/,
   'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
   'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/,
-  'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/,
+  'fi-FI': /^(\+?358|0)\s?(4[0-6]|50)\s?(\d\s?){4,8}$/,
   'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/,
   'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/,
   'fr-BF': /^(\+226|0)[67]\d{7}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 61ffe09..f290ef0 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -7835,6 +7835,9 @@ describe('Validators', () => {
           '0457 123 45 67',
           '+358457 123 45 67',
           '+358 50 555 7171',
+          '0501234',
+          '+358501234',
+          '050 1234',
         ],
         invalid: [
           '12345',
Repository: validatorjs/validator.js
Pull request #1952 (2022-04-01 09:58:18)

fix phone numner validation for ka-GE locale
https://github.com/validatorjs/validator.js/issues/1950

According https://en.wikipedia.org/wiki/Telephone_numbers_in_Georgia_(country) 
Georgian phone number should consist of 12 digits started with +9955... or +99579... for mobile numbers

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)



Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index 575415e..37d0db6 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -97,7 +97,7 @@ const phones = {
   'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/,
   'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/,
   'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/,
-  'ka-GE': /^(\+?995)?(5|79)\d{7}$/,
+  'ka-GE': /^(\+?995)?(79\d{7}|5\d{8})$/,
   '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 61ffe09..c2586a7 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -7069,18 +7069,19 @@ describe('Validators', () => {
       {
         locale: 'ka-GE',
         valid: [
-          '+99550001111',
-          '+99551535213',
+          '+995500011111',
+          '+995515352134',
           '+995798526662',
           '798526662',
-          '50001111',
+          '500011119',
           '798526662',
           '+995799766525',
         ],
         invalid: [
-          '+995500011118',
+          '+99550001111',
           '+9957997665250',
-          '+995999766525',
+          '+9959997665251',
+          '+995780011111',
           '20000000000',
           '68129485729',
           '6589394827',
Repository: validatorjs/validator.js
Pull request #1967 (2022-05-15 03:39:38)

fix(isLength): added process to subtract Presentation Sequences characters
#1941

- Added process to subtract presentation sequence characters from total characters
- Edited test


https://unicode.org/reports/tr51/#Emoji_Variation_Sequences

## 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/isLength.js b/src/lib/isLength.js
index 2e7c75c..4ef8b83 100644
--- a/src/lib/isLength.js
+++ b/src/lib/isLength.js
@@ -12,7 +12,8 @@ export default function isLength(str, options) {
     min = arguments[1] || 0;
     max = arguments[2];
   }
+  const presentationSequences = str.match(/(\uFE0F|\uFE0E)/g) || [];
   const surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || [];
-  const len = str.length - surrogatePairs.length;
+  const len = str.length - presentationSequences.length - surrogatePairs.length;
   return len >= min && (typeof max === 'undefined' || len <= max);
 }


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 16fb6b8..d49cbc8 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -4586,6 +4586,11 @@ describe('Validators', () => {
       validator: 'isLength',
       valid: ['a', '', 'asds'],
     });
+    test({
+      validator: 'isLength',
+      args: [{ max: 8 }],
+      valid: ['👩🦰👩👩👦👦🏳️🌈', '⏩︎⏩︎⏪︎⏪︎⏭︎⏭︎⏮︎⏮︎'],
+    });
   });
 
   it('should validate strings by byte length', () => {
Repository: validatorjs/validator.js
Pull request #1983 (2022-06-11 19:35:39)

fix(isMobilePhone): es-HN enhance
added the correct format for es-HN, as the numbers can start with 3 or 2.

Also added valid numbers for testing too


Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index e19184b..df5e301 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -69,7 +69,7 @@ const phones = {
   'es-CR': /^(\+506)?[2-8]\d{7}$/,
   'es-CU': /^(\+53|0053)?5\d{7}/,
   'es-DO': /^(\+?1)?8[024]9\d{7}$/,
-  'es-HN': /^(\+?504)?[9|8]\d{7}$/,
+  'es-HN': /^(\+?504)?[9|8|3|2]\d{7}$/,
   'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/,
   'es-ES': /^(\+?34)?[6|7]\d{8}$/,
   'es-PE': /^(\+?51)?9\d{8}$/,


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 16fb6b8..c522c3a 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -7623,6 +7623,10 @@ describe('Validators', () => {
           '+50489234567',
           '+50488987896',
           '+50497567389',
+          '+50427367389',
+          '+50422357389',
+          '+50431257389',
+          '+50430157389',
         ],
         invalid: [
           '12345',
Repository: validatorjs/validator.js
Pull request #1995 (2022-07-02 07:10:30)

do not check if the host is valid if no host is specified and not require_host
# Fix the isURL check to not check the host if the host part is empty and require_host is false

This PR fixes isse #1994 

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [x] README updated (where applicable)
- [x] Tests written (where applicable)



Patch:
diff --git a/src/lib/isURL.js b/src/lib/isURL.js
index aa6222a..8ed3f07 100644
--- a/src/lib/isURL.js
+++ b/src/lib/isURL.js
@@ -152,6 +152,11 @@ export default function isURL(url, options) {
   if (options.host_whitelist) {
     return checkHost(host, options.host_whitelist);
   }
+
+  if (host === '' && !options.require_host) {
+    return true;
+  }
+
   if (!isIP(host) && !isFQDN(host, options) && (!ipv6 || !isIP(ipv6, 6))) {
     return false;
   }


Test patch:
diff --git a/test/validators.js b/test/validators.js
index 50c646f..b3a39bf 100644
--- a/test/validators.js
+++ b/test/validators.js
@@ -472,6 +472,24 @@ describe('Validators', () => {
     });
   });
 
+  it('should validate postgres URLs without a host', () => {
+    test({
+      validator: 'isURL',
+      args: [{
+        protocols: ['postgres'],
+        require_host: false,
+      }],
+      valid: [
+        'postgres://user:pw@/test',
+      ],
+      invalid: [
+        'http://foobar.com',
+        'postgres://',
+      ],
+    });
+  });
+
+
   it('should validate URLs with any protocol', () => {
     test({
       validator: 'isURL',
Repository: validatorjs/validator.js
Pull request #2441 (2024-08-20 10:23:30)

feat(normalizeEmail): optional yandex domain conversion
Added an option to ignore yandex domain conversion. Currently @yandex.ua is being converted to @yandex.ru. Added support to make this behaviour optional.

Refer Issue #2440 

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [x] Tests written (where applicable)
- [ ] References provided in PR (where applicable)


profnandaa: Thanks for your PR! 🎉 

Patch:
diff --git a/src/lib/normalizeEmail.js b/src/lib/normalizeEmail.js
index a163bed..ceb252f 100644
--- a/src/lib/normalizeEmail.js
+++ b/src/lib/normalizeEmail.js
@@ -32,6 +32,8 @@ const default_normalize_email_options = {
   // The following conversions are specific to Yandex
   // Lowercases the local part of the Yandex address (known to be case-insensitive)
   yandex_lowercase: true,
+  // all yandex domains are equal, this explicitly sets the domain to 'yandex.ru'
+  yandex_convert_yandexru: true,
 
   // The following conversions are specific to iCloud
   // Lowercases the local part of the iCloud address (known to be case-insensitive)
@@ -232,7 +234,7 @@ export default function normalizeEmail(email, options) {
     if (options.all_lowercase || options.yandex_lowercase) {
       parts[0] = parts[0].toLowerCase();
     }
-    parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred
+    parts[1] = options.yandex_convert_yandexru ? 'yandex.ru' : parts[1];
   } else if (options.all_lowercase) {
     // Any other address
     parts[0] = parts[0].toLowerCase();


Test patch:
diff --git a/test/sanitizers.test.js b/test/sanitizers.test.js
index ecb0e12..e36ba48 100644
--- a/test/sanitizers.test.js
+++ b/test/sanitizers.test.js
@@ -481,5 +481,34 @@ describe('Sanitizers', () => {
         'my.self@foo.com': 'my.self@foo.com',
       },
     });
+
+    // Testing yandex_convert_yandexru
+    test({
+      sanitizer: 'normalizeEmail',
+      args: [{
+        yandex_convert_yandexru: false,
+      }],
+      expect: {
+        'test@yandex.kz': 'test@yandex.kz',
+        'test@yandex.ru': 'test@yandex.ru',
+        'test@yandex.ua': 'test@yandex.ua',
+        'test@yandex.com': 'test@yandex.com',
+        'test@yandex.by': 'test@yandex.by',
+      },
+    });
+
+    test({
+      sanitizer: 'normalizeEmail',
+      args: [{
+        yandex_convert_yandexru: true,
+      }],
+      expect: {
+        'test@yandex.kz': 'test@yandex.ru',
+        'test@yandex.ru': 'test@yandex.ru',
+        'test@yandex.ua': 'test@yandex.ru',
+        'test@yandex.com': 'test@yandex.ru',
+        'test@yandex.by': 'test@yandex.ru',
+      },
+    });
   });
 });
Repository: validatorjs/validator.js
Pull request #2482 (2024-10-23 05:20:30)

Update phone regex for Zambia
Add support for the new phone network provider for Zambia [[ref-link](https://en.wikipedia.org/wiki/Telephone_numbers_in_Zambia)
077 - Airtel (New Serial #)
076 - MTN (New Serial #)

<!--- briefly describe what you have done in this PR --->

<!--- provide some (credible) references showing the structure of the data to be validated, if applicable --->

## Checklist

- [X] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [X] Tests written (where applicable)
- [X] References provided in PR (where applicable)


sonikishan: New rebase of #2482 

Patch:
diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js
index e9932ca..53c0e37 100644
--- a/src/lib/isMobilePhone.js
+++ b/src/lib/isMobilePhone.js
@@ -70,7 +70,7 @@ const phones = {
   'en-UG': /^(\+?256|0)?[7]\d{8}$/,
   'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/,
   'en-ZA': /^(\+?27|0)\d{9}$/,
-  'en-ZM': /^(\+?26)?09[567]\d{7}$/,
+  'en-ZM': /^(\+?26)?0[79][567]\d{7}$/,
   'en-ZW': /^(\+263)[0-9]{9}$/,
   'en-BW': /^(\+?267)?(7[1-8]{1})\d{6}$/,
   'es-AR': /^\+?549(11|[2368]\d)\d{8}$/,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index 4df9139..6b61c18 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -8777,6 +8777,8 @@ describe('Validators', () => {
           '+260966684590',
           '+260976684590',
           '260976684590',
+          '+260779493521',
+          '+260760010936',
         ],
         invalid: [
           '12345',
@@ -8784,6 +8786,7 @@ describe('Validators', () => {
           'Vml2YW11cyBmZXJtZtesting123',
           '010-38238383',
           '966684590',
+          '760010936',
         ],
       },
       {
Repository: validatorjs/validator.js
Pull request #2493 (2024-11-12 21:03:55)

refactor: make brazilian postal code separator optional
separator is supposed to be at presentation layer (formatting). making it required forces applications to store uncessary data.

rubiin: can you also add new tests 
ticmaisdev: @rubiin I'm guessing it should be OK, now

Patch:
diff --git a/src/lib/isPostalCode.js b/src/lib/isPostalCode.js
index 1036562..cadf393 100644
--- a/src/lib/isPostalCode.js
+++ b/src/lib/isPostalCode.js
@@ -14,7 +14,7 @@ const patterns = {
   BA: /^([7-8]\d{4}$)/,
   BE: fourDigit,
   BG: fourDigit,
-  BR: /^\d{5}-\d{3}$/,
+  BR: /^\d{5}-?\d{3}$/,
   BY: /^2[1-4]\d{4}$/,
   CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i,
   CH: fourDigit,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index adf5d2c..af170bf 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -12742,6 +12742,9 @@ describe('Validators', () => {
           '39100-000',
           '22040-020',
           '39400-152',
+          '39100000',
+          '22040020',
+          '39400152',
         ],
         invalid: [
           '79800A12',
Repository: validatorjs/validator.js
Pull request #2518 (2025-01-16 19:06:57)

fix(isIBAN): adjusting Ireland and Palestine IBAN regex
<!--
Add a descriptive title textbox above, e.g.
feat(validatorName): brief title of what has been done
-->
## Changes:
Palestine and Ireland IBAN's should consist of `countryCode` followed by 2 numbers and then 4 `[A-Z]` symbols, not `[A-Z0-9]`. This PR adjusts these 2 regexes to follow the required standard.
<!--- briefly describe what you have done in this PR --->

<!--- provide some (credible) references showing the structure of the data to be validated, if applicable --->
## Sources:
According to [Swift](https://www.swift.com/standards/data-standards/iban-international-bank-account-number) documentation, specifically this file [here](https://www.swift.com/sites/default/files/files/iban-registry_3.pdf) 

## Checklist

- [x] PR contains only changes related; no stray files, etc.
- [ ] README updated (where applicable)
- [ ] Tests written (where applicable)
- [ ] References provided in PR (where applicable)


WikiRik: Thanks for this PR. I was able to verify that your changes seem correct. Can you add some test cases so we don't accidentally change it back?
Tarasz57: Of course. I've updated the tests to include both (previously) invalid and now correct valid IBAN's for both of these countries.

Patch:
diff --git a/src/lib/isIBAN.js b/src/lib/isIBAN.js
index 28f39be..94ac67c 100644
--- a/src/lib/isIBAN.js
+++ b/src/lib/isIBAN.js
@@ -39,7 +39,7 @@ const ibanRegexThroughCountryCode = {
   GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/,
   HR: /^(HR[0-9]{2})\d{17}$/,
   HU: /^(HU[0-9]{2})\d{24}$/,
-  IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/,
+  IE: /^(IE[0-9]{2})[A-Z]{4}\d{14}$/,
   IL: /^(IL[0-9]{2})\d{19}$/,
   IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/,
   IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/,
@@ -67,7 +67,7 @@ const ibanRegexThroughCountryCode = {
   NO: /^(NO[0-9]{2})\d{11}$/,
   PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/,
   PL: /^(PL[0-9]{2})\d{24}$/,
-  PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/,
+  PS: /^(PS[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
   PT: /^(PT[0-9]{2})\d{21}$/,
   QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/,
   RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/,


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index aa13906..d0908ad 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -5857,6 +5857,9 @@ describe('Validators', () => {
         'MA64011519000001205000534921',
         'VG96VPVG0000012345678901',
         'DZ580002100001113000000570',
+        'IE29AIBK93115212345678',
+        'PS92PALS000000000400123456702',
+        'PS92PALS00000000040012345670O',
       ],
       invalid: [
         'XX22YYY1234567890123',
@@ -5865,6 +5868,8 @@ describe('Validators', () => {
         'FR7630006000011234567890189😅',
         'FR763000600001123456!!🤨7890189@',
         'VG46H07Y0223060094359858',
+        'IE95TE8270900834048660',
+        'PS072435171802145240705922007',
       ],
     });
     test({