Skip to content

Commit 32b174e

Browse files
authored
feat(isLicensePlate): Support for Pakistani vehicles (#2207)
* Pakistan vehicles license plate support * Readme and test cases updated * Update README.md
1 parent b34a335 commit 32b174e

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Validator | Description
142142
**isJWT(str)** | check if the string is valid JWT token.
143143
**isLatLong(str [, options])** | check if the string is a valid latitude-longitude coordinate in the format `lat,long` or `lat, long`.<br/><br/>`options` is an object that defaults to `{ checkDMS: false }`. Pass `checkDMS` as `true` to validate DMS(degrees, minutes, and seconds) latitude-longitude format.
144144
**isLength(str [, options])** | check if the string's length falls in a range.<br/><br/>`options` is an object which defaults to `{ min: 0, max: undefined }`. Note: this function takes into account surrogate pairs.
145-
**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.<br/><br/>`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE']` or `'any'`.
145+
**isLicensePlate(str, locale)** | check if the string matches the format of a country's license plate.<br/><br/>`locale` is one of `['cs-CZ', 'de-DE', 'de-LI', 'en-IN', 'en-PK', 'es-AR', 'hu-HU', 'pt-BR', 'pt-PT', 'sq-AL', 'sv-SE']` or `'any'`.
146146
**isLocale(str)** | check if the string is a locale.
147147
**isLowercase(str)** | check if the string is lowercase.
148148
**isLuhnNumber(str)** | check if the string passes the [Luhn algorithm check](https://en.wikipedia.org/wiki/Luhn_algorithm).

src/lib/isLicensePlate.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/validators.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13631,6 +13631,30 @@ describe('Validators', () => {
1363113631
],
1363213632
invalid: ['mh04ad0045', 'invalidlicenseplate', '4578', '', 'GJ054GH4785'],
1363313633
});
13634+
test({
13635+
validator: 'isLicensePlate',
13636+
args: ['en-PK'],
13637+
valid: [
13638+
'P 1789',
13639+
'RL745',
13640+
'RIR 5421',
13641+
'KHI 201',
13642+
'LB6571',
13643+
'LHR-786-23',
13644+
'AJGB 816-10',
13645+
'LES 7891 06',
13646+
'IDS 7871',
13647+
'LEH 4607 15',
13648+
],
13649+
invalid: [
13650+
'ajgb 816-10',
13651+
' 278-37',
13652+
'ABZ-27',
13653+
'',
13654+
'ABC-123-',
13655+
'D 272',
13656+
],
13657+
});
1363413658
});
1363513659
it('should validate VAT numbers', () => {
1363613660
test({

0 commit comments

Comments
 (0)