Repository: validatorjs/validator.js
Pull request #2555 (2025-04-18 00:39:15)

feat(isLicensePlate): Updated isLicensePlate to accept real pt-PT license plates.
I have updated the isLicensePlate pt-PT regex to accept actual valid license plates in Portugal.

Image as an example of valid license plates.
![image](https://github.com/user-attachments/assets/327323ab-3ba8-43b2-9041-4aa9a2a87d81)



codecov[bot]: ## [Codecov](https://app.codecov.io/gh/validatorjs/validator.js/pull/2555?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 100.00%. Comparing base [(`d07eae6`)](https://app.codecov.io/gh/validatorjs/validator.js/commit/d07eae6cdaf49af6a44b0731b00b0de9827c8019?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs) to head [(`e3528be`)](https://app.codecov.io/gh/validatorjs/validator.js/commit/e3528be53962c964e1a4eccd74e91d20c362b24e?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##            master     #2555   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2535      2535           
  Branches       641       641           
=========================================
  Hits          2535      2535           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/validatorjs/validator.js/pull/2555?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=validatorjs).

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
WikiRik: Can you provide a link to the source where you made the screenshot from?
castrosu: > Can you provide a link to the source where you made the screenshot from?

Of course, here you go https://aran.pt/pt/matriculas-por-ano
castrosu: can someone approve this? without this the current regex check doesn't pass all tests for pt-PT license plate in this PR

Patch:
diff --git a/src/lib/isLicensePlate.js b/src/lib/isLicensePlate.js
index bd146be..54d8063 100644
--- a/src/lib/isLicensePlate.js
+++ b/src/lib/isLicensePlate.js
@@ -14,7 +14,7 @@ const validators = {
   'pt-BR': str =>
     /^[A-Z]{3}[ -]?[0-9][A-Z][0-9]{2}|[A-Z]{3}[ -]?[0-9]{4}$/.test(str),
   'pt-PT': str =>
-    /^([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})[ -·]?([A-Z]{2}|[0-9]{2})$/.test(str),
+    /^(([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[A-Z]{2}[ -·]?[0-9]{2})|([0-9]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2})|([A-Z]{2}[ -·]?[0-9]{2}[ -·]?[A-Z]{2}))$/.test(str),
   'sq-AL': str =>
     /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str),
   'sv-SE': str =>


Test patch:
diff --git a/test/validators.test.js b/test/validators.test.js
index c168103..7c8c495 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -14317,16 +14317,42 @@ describe('Validators', () => {
       args: ['pt-PT'],
       valid: [
         'AA-12-34',
-        '12·34·AB',
+        '12-AA-34',
+        '12-34-AA',
+        'AA-12-AA',
+        'AA·12·34',
         '12·AB·34',
+        '12·34·AB',
+        'AB·34·AB',
+        'AA 12 34',
+        '12 AA 34',
+        '12 34 AA',
         'AB 12 CD',
+        'AA1234',
+        '12AA34',
+        '1234AA',
         'AB12CD',
       ],
       invalid: [
         '',
         'notalicenseplate',
+        'AA-AA-00',
+        '00-AA-AA',
+        'AA-AA-AA',
+        '00-00-00',
+        'AA·AA·00',
+        '00·AA·AA',
+        'AA·AA·AA',
+        '00·00·00',
+        'AA AA 00',
+        '00 AA AA',
+        'AA AA AA',
+        '00 00 00',
         'A1-B2-C3',
+        '1A-2B-3C',
         'ABC-1-EF',
+        'AB-C1D-EF',
+        'AB-C1-DEF',
       ],
     });
     test({