Skip to content

Commit

Permalink
feat(isLicensePlate): Support for Pakistani vehicles (#2207)
Browse files Browse the repository at this point in the history
* Pakistan vehicles license plate support

* Readme and test cases updated

* Update README.md
  • Loading branch information
anasshakil committed Apr 25, 2024
1 parent b34a335 commit 32b174e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -142,7 +142,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`.<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.
**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.
**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'`.
**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'`.
**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).
Expand Down
1 change: 1 addition & 0 deletions src/lib/isLicensePlate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions test/validators.test.js
Expand Up @@ -13631,6 +13631,30 @@ describe('Validators', () => {
],
invalid: ['mh04ad0045', 'invalidlicenseplate', '4578', '', 'GJ054GH4785'],
});
test({
validator: 'isLicensePlate',
args: ['en-PK'],
valid: [
'P 1789',
'RL745',
'RIR 5421',
'KHI 201',
'LB6571',
'LHR-786-23',
'AJGB 816-10',
'LES 7891 06',
'IDS 7871',
'LEH 4607 15',
],
invalid: [
'ajgb 816-10',
' 278-37',
'ABZ-27',
'',
'ABC-123-',
'D 272',
],
});
});
it('should validate VAT numbers', () => {
test({
Expand Down

0 comments on commit 32b174e

Please sign in to comment.