From 3cd0b5acccc812f4ecdf7c33fda1d3bea854d95b Mon Sep 17 00:00:00 2001
From: Bahri Yilmaz <87454324+bahriy-dev@users.noreply.github.com>
Date: Fri, 13 Nov 2026 06:54:32 +0300
Subject: [PATCH] feat(isLicensePlate): add tr-TR locale
---
README.md | 2 +-
src/lib/isLicensePlate.js | 2 ++
test/validators.test.js | 33 +++++++++++++++++++++++++++++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e8b7aedd9..244e7ab65 100644
--- a/README.md
+++ b/README.md
@@ -141,7 +141,7 @@ Validator | Description
**isJWT(str)** | check if the string is valid JWT token.
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.
`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
**isLength(str [, options])** | check if the string's length falls in a range and equal to any of the integers of the `discreteLengths` array if provided.
`options` is an object which defaults to `{ min: 0, max: undefined, discreteLengths: undefined }`. Note: this function takes into account surrogate pairs.
-**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.
`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'en-SG', 'en-PK', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE']` or `'any'`.
+**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.
`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'en-SG', 'en-PK', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE', 'tr-TR']` or `'any'`.
**isLocale(str)** | check if the string is a locale.
**isLowercase(str)** | check if the string is lowercase.
**isLuhnNumber(str)** | check if the string passes the [Luhn algorithm check](https://en.wikipedia.org/wiki/Luhn_algorithm).
diff --git a/src/lib/isLicensePlate.js b/src/lib/isLicensePlate.js
index 54d80635f..69e6dbc72 100644
--- a/src/lib/isLicensePlate.js
+++ b/src/lib/isLicensePlate.js
@@ -17,6 +17,8 @@ const validators = {
/^(([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),
+ 'tr-TR': str =>
+ /^(0[1-9]|[1-7][0-9]|8[01]) ?([A-PR-VYZ] ?\d{4,5}|[A-PR-VYZ]{2} ?\d{3,4}|[A-PR-VYZ]{3} ?\d{2,3})$/.test(str),
'sv-SE': str =>
/^[A-HJ-PR-UW-Z]{3} ?[\d]{2}[A-HJ-PR-UW-Z1-9]$|(^[A-ZÅÄÖ ]{2,7}$)/.test(str.trim()),
'en-PK': str => /(^[A-Z]{2}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{3}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]{4}((\s|-){0,1})[0-9]{3,4}((\s|-)[0-9]{2}){0,1}$)|(^[A-Z]((\s|-){0,1})[0-9]{4}((\s|-)[0-9]{2}){0,1}$)/.test(str.trim()),
diff --git a/test/validators.test.js b/test/validators.test.js
index 98d2a12ff..efd75844b 100644
--- a/test/validators.test.js
+++ b/test/validators.test.js
@@ -15237,6 +15237,39 @@ describe('Validators', () => {
'GJ054GH4785',
],
});
+ test({
+ validator: 'isLicensePlate',
+ args: ['tr-TR'],
+ valid: [
+ '34 A 1234',
+ '06 A 12345',
+ '35 AB 123',
+ '01 AB 1234',
+ '81 ABC 12',
+ '16 ABC 123',
+ '34ABC123',
+ '07 IR 123',
+ ],
+ invalid: [
+ '',
+ '00 A 1234',
+ '82 AB 123',
+ '34 A 123',
+ '34 A 123456',
+ '34 AB 12',
+ '34 AB 12345',
+ '34 ABC 1',
+ '34 ABC 1234',
+ '34 ABCD 12',
+ '34 QA 123',
+ '34 WX 123',
+ '34 ÇŞ 123',
+ '34 İA 123',
+ '34 ab 123',
+ '34-AB-123',
+ '4 AB 123',
+ ],
+ });
});
it('should validate VAT numbers', () => {
test({