From 72b2902aab6b69f38e4330b3183b9c543d41d67e Mon Sep 17 00:00:00 2001 From: Vic <74975015+vicuts@users.noreply.github.com> Date: Sun, 4 Oct 2026 04:40:22 +0300 Subject: [PATCH] feat(isLicensePlate): add ro-RO locale --- README.md | 2 +- src/lib/isLicensePlate.js | 2 ++ test/validators.test.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e8b7aedd9..9958cc807 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', 'ro-RO', 'sq-AL', 'sv-SE']` 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..c2acc66ae 100644 --- a/src/lib/isLicensePlate.js +++ b/src/lib/isLicensePlate.js @@ -15,6 +15,8 @@ const validators = { /^[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}[ -·]?[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), + 'ro-RO': str => + /^(B[- ]?(0[1-9]|[1-9]\d{1,2})|(AB|AG|AR|BC|BH|BN|BR|BT|BV|BZ|CJ|CL|CS|CT|CV|DB|DJ|GJ|GL|GR|HD|HR|IF|IL|IS|MH|MM|MS|NT|OT|PH|SB|SJ|SM|SV|TL|TM|TR|VL|VN|VS)[- ]?(0[1-9]|[1-9]\d))[- ]?[A-HJ-NPR-Z][A-PR-Z]{2}$/.test(str), 'sq-AL': str => /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str), 'sv-SE': str => diff --git a/test/validators.test.js b/test/validators.test.js index 98d2a12ff..fe5a84534 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -15029,6 +15029,35 @@ describe('Validators', () => { 'AAA 00 AAA', ], }); + test({ + validator: 'isLicensePlate', + args: ['ro-RO'], + valid: [ + 'B 12 ABC', + 'B 123 ABC', + 'B 01 XYZ', + 'B123ABC', + 'CJ 12 ABC', + 'CJ-05-XYZ', + 'AB 01 AAA', + 'VS99ZZZ', + ], + invalid: [ + '', + 'B 00 ABC', + 'B 012 ABC', + 'B 1234 ABC', + 'CJ 00 ABC', + 'CJ 123 ABC', + 'CJ 12 AB', + 'CJ 12 IAB', + 'CJ 12 OAB', + 'CJ 12 AQB', + 'XX 12 ABC', + 'cj 12 abc', + 'CJ 12 ABC', + ], + }); test({ validator: 'isLicensePlate', args: ['cs-CZ'],