-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(isLicensePlate): Introduction with locales for Germany, Liechtenstein, Portugal and Albania #1495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(isLicensePlate): Introduction with locales for Germany, Liechtenstein, Portugal and Albania #1495
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f4f4c63
Added isLicensePlate check with german locale
firlus 9c72902
de-LI (Liechtenstein) validator
firlus 2ead777
Added albanian number plates
firlus a4dda0e
reversed changes in index.js
firlus 04bad3b
reversed changes in index.js
firlus d60962f
Refactored de-DE into one big regex, expanded tests fot de-DE
firlus 80c1437
added pt-PT locale
firlus 87d02ee
Fixed coverage problem
firlus 1547be5
merged from validator.js/master and solved merge conflicts
firlus 1b961d7
feat(isLicensePlate): clean build
firlus 88fb830
coverage is now 100%
firlus b897b62
Merge branch 'master' into addLicensePlate
firlus 0150b59
Update README.md
firlus 37df91c
Update README.md
firlus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import assertString from './util/assertString'; | ||
|
|
||
| const validators = { | ||
| 'de-LI': str => /^FL[- ]?\d{1-5}[UZ]?$/.test(str), | ||
| 'sq-AL': str => /^[A-Z]{2}[- ]?((\d{3}[- ]?(([A-Z]{2})|T))|(R[- ]?\d{3}))$/.test(str), | ||
| 'de-DE': (str) => { | ||
| // Rule 1: License plate must match regex | ||
| const regex = /^[A-Z]{1,3}[- ]?[A-Z]{1,2}[- ]?[0-9]{1,4}$/; | ||
| const plateSections = str.split(/[ -]/g); | ||
| const validFormat = regex.test(str); | ||
| // Rule 2: First section (1-3 letters until sepatator) must be a valid county code | ||
| const countyCodes = [ | ||
| 'AW', 'AIC', 'FDB', 'UL', 'ABG', 'SLN', 'AK', 'SAW', 'GA', 'KLZ', 'AÖ', | ||
| 'LF', 'AZ', 'AM', 'AS', 'BUL', 'ESB', 'NAB', 'SUL', 'WST', 'ABI', 'AZE', | ||
| 'BTF', 'KÖT', 'ZE', 'AN', 'DKB', 'FEU', 'ROT', 'AB', 'ALZ', 'A', 'SMÜ', | ||
| 'WER', 'AUR', 'NOR', 'DÜW', 'KG', 'BRK', 'HAB', 'KH', 'TÖL', 'WOR', 'BAD', | ||
| 'BA', 'BAR', 'BER', 'EW', 'BZ', 'BIW', 'HY', 'KM', 'BT', 'EBS', 'KEM', | ||
| 'MÜB', 'PEG', 'BGL', 'BGD', 'REI', 'HP', 'B', 'WIL', 'BKS', 'BC', 'BI', | ||
| 'BIR', 'BO', 'WAT', 'FN', 'TT', 'ÜB', 'BN', 'BOR', 'AH', 'BOH', 'BOT', | ||
| 'BRB', 'BS', 'FR', 'HB', 'BLK', 'HHM', 'NEB', 'NMB', 'WSF', 'ZZ', 'BB', | ||
| 'LEO', 'BK', 'BÖ', 'HDL', 'OC', 'OK', 'WMS', 'WZL', 'BÜS', 'CW', 'CE', | ||
| 'CHA', 'KÖZ', 'ROD', 'WÜM', 'C', 'CLP', 'CO', 'NEC', 'COC', 'ZEL', 'COE', | ||
| 'LH', 'CB', 'CUX', 'DAH', 'LDS', 'KW', 'LC', 'LN', 'DA', 'DI', 'DEG', | ||
| 'DEL', 'DE', 'RSL', 'DH', 'SY', 'DLG', 'DGF', 'LAN', 'HEI', 'MED', 'DON', | ||
| 'NÖ', 'KIB', 'ROK', 'DO', 'DD', 'DU', 'DN', 'JÜL', 'MON', 'SLE', 'D', | ||
| 'EBE', 'EIC', 'HIG', 'WBS', 'EI', 'BIT', 'PRÜ', 'EA', 'EE', 'FI', 'LIB', | ||
| 'EMD', 'EM', 'EL', 'EN', 'WIT', 'PF', 'ED', 'EF', 'ER', 'ERH', 'HÖS', | ||
| 'ERZ', 'ANA', 'ASZ', 'AU', 'MAB', 'MEK', 'STL', 'SZB', 'ZP', 'E', 'ES', | ||
| 'NT', 'EU', 'FL', 'FO', 'FT', 'FF', 'F', 'FS', 'FDS', 'HCH', 'HOR', | ||
| 'WOL', 'FRG', 'GRA', 'WOS', 'FRI', 'FD', 'FFB', 'FÜ', 'GAP', 'GE', 'G', | ||
| 'GER', 'GI', 'GF', 'GS', 'BRL', 'CLZ', 'GTH', 'NOH', 'HGW', 'GRZ', 'ZR', | ||
| 'GG', 'GP', 'GR', 'LÖB', 'NOL', 'NY', 'WSW', 'ZI', 'GÖ', 'DUD', 'HMÜ', | ||
| 'OHA', 'GZ', 'KRU', 'GT', 'HA', 'HAL', 'HH', 'HM', 'HAM', 'HU', 'WL', | ||
| 'HZ', 'HBS', 'QLB', 'WR', 'HVL', 'NAU', 'RN', 'HAS', 'EBN', 'GEO', 'HOH', | ||
| 'HK', 'HD', 'HDH', 'HN', 'HS', 'ERK', 'GK', 'HE', 'HF', 'HER', 'WAN', | ||
| 'HEF', 'ROF', 'RZ', 'HBN', 'HI', 'ALF', 'HSK', 'HG', 'USI', 'HO', 'NAI', | ||
| 'REH', 'SAN', 'KÜN', 'ÖHR', 'HOL', 'HX', 'WAR', 'IK', 'ARN', 'IL', 'IN', | ||
| 'J', 'JL', 'BRG', 'GNT', 'KL', 'KA', 'KS', 'HOG', 'WOH', 'KF', 'KEH', | ||
| 'MAI', 'PAR', 'RID', 'ROL', 'KE', 'KI', 'KT', 'KLE', 'GEL', 'KO', 'KN', | ||
| 'KR', 'KC', 'KU', 'KUS', 'KYF', 'ART', 'SDH', 'K', 'LDK', 'DIL', 'LD', | ||
| 'LL', 'LA', 'MAL', 'VIB', 'LER', 'L', 'BNA', 'GHA', 'GRM', 'MTL', 'WUR', | ||
| 'LEV', 'OP', 'LIF', 'STE', 'LM', 'WEL', 'LI', 'LIP', 'LB', 'VAI', 'LU', | ||
| 'LUP', 'HGN', 'LBZ', 'LWL', 'PCH', 'STB', 'LÖ', 'HL', 'DAN', 'LG', 'MD', | ||
| 'MKK', 'GN', 'SLÜ', 'MSP', 'TBB', 'MGH', 'MTK', 'MZ', 'BIN', 'MA', 'MSH', | ||
| 'EIL', 'HET', 'ML', 'SGH', 'MR', 'BID', 'MYK', 'MY', 'MSE', 'AT', 'DM', | ||
| 'MC', 'MST', 'MÜR', 'NZ', 'RM', 'WRN', 'MEI', 'GRH', 'RG', 'RIE', 'MM', | ||
| 'MZG', 'ME', 'MB', 'MIL', 'OBB', 'MI', 'FG', 'BED', 'DL', 'FLÖ', 'HC', | ||
| 'MW', 'RL', 'MOL', 'FRW', 'SEE', 'SRB', 'MK', 'MG', 'MÜ', 'WS', 'MH', | ||
| 'M', 'AIB', 'MS', 'MOS', 'BCH', 'NU', 'ILL', 'NB', 'ND', 'SOB', 'NM', | ||
| 'NMS', 'NK', 'NEA', 'SEF', 'UFF', 'NEW', 'VOH', 'NW', 'NR', 'NI', 'NF', | ||
| 'NDH', 'TDO', 'DZ', 'EB', 'OZ', 'TG', 'TO', 'NWM', 'GDB', 'GVM', 'WIS', | ||
| 'NOM', 'EIN', 'GAN', 'N', 'LAU', 'HEB', 'OA', 'GM', 'OB', 'OHV', 'OSL', | ||
| 'CA', 'SFB', 'ERB', 'LOS', 'BSK', 'EH', 'FW', 'OF', 'OL', 'OE', 'OG', | ||
| 'BH', 'KEL', 'LR', 'OS', 'BSB', 'MEL', 'WTL', 'AA', 'GD', 'OAL', 'FÜS', | ||
| 'MOD', 'OHZ', 'OH', 'OPR', 'KY', 'NP', 'WK', 'PB', 'BÜR', 'PA', 'PE', | ||
| 'PAF', 'PI', 'PS', 'PLÖ', 'P', 'PM', 'PR', 'RA', 'RV', 'RE', 'CAS', | ||
| 'GLA', 'REG', 'VIT', 'R', 'H', 'SB', 'WN', 'RS', 'RD', 'ECK', 'RT', | ||
| 'BM', 'SIM', 'GOA', 'NE', 'GV', 'EMS', 'DIZ', 'GOH', 'RP', 'SU', 'RÜD', | ||
| 'SWA', 'GL', 'NES', 'KÖN', 'MET', 'RO', 'LRO', 'BÜZ', 'DBR', 'GÜ', 'ROS', | ||
| 'TET', 'HRO', 'ROW', 'BRV', 'RH', 'HIP', 'PAN', 'EG', 'GRI', 'RW', 'SHK', | ||
| 'EIS', 'SRO', 'SOK', 'LBS', 'PN', 'SCZ', 'SK', 'MER', 'MQ', 'QFT', 'SLF', | ||
| 'RU', 'SLS', 'HOM', 'SZ', 'SLK', 'ASL', 'BBG', 'SBK', 'SFT', 'SHG', 'RI', | ||
| 'SL', 'SM', 'MGN', 'SC', 'HR', 'FZ', 'MEG', 'ZIG', 'SAD', 'NEN', 'OVI', | ||
| 'VS', 'SW', 'SN', 'SHA', 'CR', 'SE', 'SI', 'BLB', 'SIG', 'SO', 'LP', | ||
| 'SG', 'SON', 'NH', 'SP', 'SPN', 'FOR', 'GUB', 'SPB', 'IGB', 'WND', 'STD', | ||
| 'STA', 'IZ', 'ST', 'BF', 'TE', 'SDL', 'HV', 'OBG', 'OD', 'HST', 'SR', | ||
| 'BOG', 'S', 'AC', 'SHL', 'PIR', 'DW', 'FTL', 'SEB', 'SÖM', 'SÜW', 'ZW', | ||
| 'TF', 'TIR', 'TS', 'TR', 'SAB', 'TUT', 'TÜ', 'UM', 'ANG', 'PZ', 'SDT', | ||
| 'TP', 'UE', 'UN', 'LÜN', 'UH', 'LSZ', 'MHL', 'MN', 'VEC', 'VER', 'VIE', | ||
| 'KK', 'VB', 'V', 'AE', 'OVL', 'PL', 'RC', 'VG', 'ANK', 'GW', 'OVP', | ||
| 'PW', 'SBG', 'UEM', 'UER', 'WLG', 'VR', 'GMN', 'NVP', 'RDG', 'RÜG', 'DAU', | ||
| 'VK', 'KB', 'FKB', 'WA', 'WT', 'WAF', 'BE', 'WAK', 'SLZ', 'WEN', 'WM', | ||
| 'SOG', 'WE', 'AP', 'APD', 'WUG', 'GUN', 'ESW', 'WIZ', 'WES', 'DIN', 'MO', | ||
| 'BRA', 'WW', 'FB', 'BÜD', 'WZ', 'WI', 'WHV', 'HWI', 'WB', 'GHC', 'JE', | ||
| 'WTM', 'WF', 'WOB', 'WO', 'WUN', 'MAK', 'SEL', 'W', 'WÜ', 'OCH', 'BL', | ||
| 'Z', 'GC', 'HOT', 'WDA', | ||
| ]; | ||
| const validCountyCode = countyCodes.includes(plateSections[0]); | ||
| // Rule 3: Certain letter combinations are forbidden in the middle section | ||
| const forbiddenMiddleSections = ['KZ', 'HJ', 'NS', 'SA', 'SS']; | ||
| const noForbiddenMiddleSection = !forbiddenMiddleSections.includes(plateSections[1]); | ||
| // Rule 4: No license plate must be longer then 8 characters. | ||
| const validLength = `${plateSections[0]}${plateSections[1]}${plateSections[2]}`.length <= 8; | ||
| return validFormat && validCountyCode && noForbiddenMiddleSection && validLength; | ||
| }, | ||
| }; | ||
|
|
||
| export default function isLicensePlate(str, locale) { | ||
| assertString(str); | ||
| if (locale in validators) { | ||
| return validators[locale](str); | ||
| } else if (locale === 'any') { | ||
| for (const key in validators) { | ||
| // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes | ||
| // istanbul ignore else | ||
| if (validators.hasOwnProperty(key)) { | ||
| const validator = validators[key]; | ||
| if (validator(str)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
| throw new Error(`Invalid locale '${locale}'`); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3071,6 +3071,47 @@ function isSlug(str) { | |
| return charsetRegex.test(str); | ||
| } | ||
|
|
||
| var validators$1 = { | ||
| 'de-DE': function deDE(str) { | ||
| // Rule 1: License plate must match regex | ||
| var regex = /^[A-Z]{1,3}[- ][A-Z]{1,2}[- ][0-9]{1,4}$/; | ||
| var plateSections = str.split(/[ -]/g); | ||
| var validFormat = regex.test(str); // Rule 2: First section (1-3 letters until sepatator) must be a valid county code | ||
|
|
||
| var countyCodes = ['AW', 'AIC', 'FDB', 'UL', 'ABG', 'SLN', 'AK', 'SAW', 'GA', 'KLZ', 'AÖ', 'LF', 'AZ', 'AM', 'AS', 'BUL', 'ESB', 'NAB', 'SUL', 'WST', 'ABI', 'AZE', 'BTF', 'KÖT', 'ZE', 'AN', 'DKB', 'FEU', 'ROT', 'AB', 'ALZ', 'A', 'SMÜ', 'WER', 'AUR', 'NOR', 'DÜW', 'KG', 'BRK', 'HAB', 'KH', 'TÖL', 'WOR', 'BAD', 'BA', 'BAR', 'BER', 'EW', 'BZ', 'BIW', 'HY', 'KM', 'BT', 'EBS', 'KEM', 'MÜB', 'PEG', 'BGL', 'BGD', 'REI', 'HP', 'B', 'WIL', 'BKS', 'BC', 'BI', 'BIR', 'BO', 'WAT', 'FN', 'TT', 'ÜB', 'BN', 'BOR', 'AH', 'BOH', 'BOT', 'BRB', 'BS', 'FR', 'HB', 'BLK', 'HHM', 'NEB', 'NMB', 'WSF', 'ZZ', 'BB', 'LEO', 'BK', 'BÖ', 'HDL', 'OC', 'OK', 'WMS', 'WZL', 'BÜS', 'CW', 'CE', 'CHA', 'KÖZ', 'ROD', 'WÜM', 'C', 'CLP', 'CO', 'NEC', 'COC', 'ZEL', 'COE', 'LH', 'CB', 'CUX', 'DAH', 'LDS', 'KW', 'LC', 'LN', 'DA', 'DI', 'DEG', 'DEL', 'DE', 'RSL', 'DH', 'SY', 'DLG', 'DGF', 'LAN', 'HEI', 'MED', 'DON', 'NÖ', 'KIB', 'ROK', 'DO', 'DD', 'DU', 'DN', 'JÜL', 'MON', 'SLE', 'D', 'EBE', 'EIC', 'HIG', 'WBS', 'EI', 'BIT', 'PRÜ', 'EA', 'EE', 'FI', 'LIB', 'EMD', 'EM', 'EL', 'EN', 'WIT', 'PF', 'ED', 'EF', 'ER', 'ERH', 'HÖS', 'ERZ', 'ANA', 'ASZ', 'AU', 'MAB', 'MEK', 'STL', 'SZB', 'ZP', 'E', 'ES', 'NT', 'EU', 'FL', 'FO', 'FT', 'FF', 'F', 'FS', 'FDS', 'HCH', 'HOR', 'WOL', 'FRG', 'GRA', 'WOS', 'FRI', 'FD', 'FFB', 'FÜ', 'GAP', 'GE', 'G', 'GER', 'GI', 'GF', 'GS', 'BRL', 'CLZ', 'GTH', 'NOH', 'HGW', 'GRZ', 'ZR', 'GG', 'GP', 'GR', 'LÖB', 'NOL', 'NY', 'WSW', 'ZI', 'GÖ', 'DUD', 'HMÜ', 'OHA', 'GZ', 'KRU', 'GT', 'HA', 'HAL', 'HH', 'HM', 'HAM', 'HU', 'WL', 'HZ', 'HBS', 'QLB', 'WR', 'HVL', 'NAU', 'RN', 'HAS', 'EBN', 'GEO', 'HOH', 'HK', 'HD', 'HDH', 'HN', 'HS', 'ERK', 'GK', 'HE', 'HF', 'HER', 'WAN', 'HEF', 'ROF', 'RZ', 'HBN', 'HI', 'ALF', 'HSK', 'HG', 'USI', 'HO', 'NAI', 'REH', 'SAN', 'KÜN', 'ÖHR', 'HOL', 'HX', 'WAR', 'IK', 'ARN', 'IL', 'IN', 'J', 'JL', 'BRG', 'GNT', 'KL', 'KA', 'KS', 'HOG', 'WOH', 'KF', 'KEH', 'MAI', 'PAR', 'RID', 'ROL', 'KE', 'KI', 'KT', 'KLE', 'GEL', 'KO', 'KN', 'KR', 'KC', 'KU', 'KUS', 'KYF', 'ART', 'SDH', 'K', 'LDK', 'DIL', 'LD', 'LL', 'LA', 'MAL', 'VIB', 'LER', 'L', 'BNA', 'GHA', 'GRM', 'MTL', 'WUR', 'LEV', 'OP', 'LIF', 'STE', 'LM', 'WEL', 'LI', 'LIP', 'LB', 'VAI', 'LU', 'LUP', 'HGN', 'LBZ', 'LWL', 'PCH', 'STB', 'LÖ', 'HL', 'DAN', 'LG', 'MD', 'MKK', 'GN', 'SLÜ', 'MSP', 'TBB', 'MGH', 'MTK', 'MZ', 'BIN', 'MA', 'MSH', 'EIL', 'HET', 'ML', 'SGH', 'MR', 'BID', 'MYK', 'MY', 'MSE', 'AT', 'DM', 'MC', 'MST', 'MÜR', 'NZ', 'RM', 'WRN', 'MEI', 'GRH', 'RG', 'RIE', 'MM', 'MZG', 'ME', 'MB', 'MIL', 'OBB', 'MI', 'FG', 'BED', 'DL', 'FLÖ', 'HC', 'MW', 'RL', 'MOL', 'FRW', 'SEE', 'SRB', 'MK', 'MG', 'MÜ', 'WS', 'MH', 'M', 'AIB', 'MS', 'MOS', 'BCH', 'NU', 'ILL', 'NB', 'ND', 'SOB', 'NM', 'NMS', 'NK', 'NEA', 'SEF', 'UFF', 'NEW', 'VOH', 'NW', 'NR', 'NI', 'NF', 'NDH', 'TDO', 'DZ', 'EB', 'OZ', 'TG', 'TO', 'NWM', 'GDB', 'GVM', 'WIS', 'NOM', 'EIN', 'GAN', 'N', 'LAU', 'HEB', 'OA', 'GM', 'OB', 'OHV', 'OSL', 'CA', 'SFB', 'ERB', 'LOS', 'BSK', 'EH', 'FW', 'OF', 'OL', 'OE', 'OG', 'BH', 'KEL', 'LR', 'OS', 'BSB', 'MEL', 'WTL', 'AA', 'GD', 'OAL', 'FÜS', 'MOD', 'OHZ', 'OH', 'OPR', 'KY', 'NP', 'WK', 'PB', 'BÜR', 'PA', 'PE', 'PAF', 'PI', 'PS', 'PLÖ', 'P', 'PM', 'PR', 'RA', 'RV', 'RE', 'CAS', 'GLA', 'REG', 'VIT', 'R', 'H', 'SB', 'WN', 'RS', 'RD', 'ECK', 'RT', 'BM', 'SIM', 'GOA', 'NE', 'GV', 'EMS', 'DIZ', 'GOH', 'RP', 'SU', 'RÜD', 'SWA', 'GL', 'NES', 'KÖN', 'MET', 'RO', 'LRO', 'BÜZ', 'DBR', 'GÜ', 'ROS', 'TET', 'HRO', 'ROW', 'BRV', 'RH', 'HIP', 'PAN', 'EG', 'GRI', 'RW', 'SHK', 'EIS', 'SRO', 'SOK', 'LBS', 'PN', 'SCZ', 'SK', 'MER', 'MQ', 'QFT', 'SLF', 'RU', 'SLS', 'HOM', 'SZ', 'SLK', 'ASL', 'BBG', 'SBK', 'SFT', 'SHG', 'RI', 'SL', 'SM', 'MGN', 'SC', 'HR', 'FZ', 'MEG', 'ZIG', 'SAD', 'NEN', 'OVI', 'VS', 'SW', 'SN', 'SHA', 'CR', 'SE', 'SI', 'BLB', 'SIG', 'SO', 'LP', 'SG', 'SON', 'NH', 'SP', 'SPN', 'FOR', 'GUB', 'SPB', 'IGB', 'WND', 'STD', 'STA', 'IZ', 'ST', 'BF', 'TE', 'SDL', 'HV', 'OBG', 'OD', 'HST', 'SR', 'BOG', 'S', 'AC', 'SHL', 'PIR', 'DW', 'FTL', 'SEB', 'SÖM', 'SÜW', 'ZW', 'TF', 'TIR', 'TS', 'TR', 'SAB', 'TUT', 'TÜ', 'UM', 'ANG', 'PZ', 'SDT', 'TP', 'UE', 'UN', 'LÜN', 'UH', 'LSZ', 'MHL', 'MN', 'VEC', 'VER', 'VIE', 'KK', 'VB', 'V', 'AE', 'OVL', 'PL', 'RC', 'VG', 'ANK', 'GW', 'OVP', 'PW', 'SBG', 'UEM', 'UER', 'WLG', 'VR', 'GMN', 'NVP', 'RDG', 'RÜG', 'DAU', 'VK', 'KB', 'FKB', 'WA', 'WT', 'WAF', 'BE', 'WAK', 'SLZ', 'WEN', 'WM', 'SOG', 'WE', 'AP', 'APD', 'WUG', 'GUN', 'ESW', 'WIZ', 'WES', 'DIN', 'MO', 'BRA', 'WW', 'FB', 'BÜD', 'WZ', 'WI', 'WHV', 'HWI', 'WB', 'GHC', 'JE', 'WTM', 'WF', 'WOB', 'WO', 'WUN', 'MAK', 'SEL', 'W', 'WÜ', 'OCH', 'BL', 'Z', 'GC', 'HOT', 'WDA']; | ||
|
||
| var validCountyCode = countyCodes.includes(plateSections[0]); // Rule 3: Certain letter combinations are forbidden in the middle section | ||
|
|
||
| var forbiddenMiddleSections = ['KZ', 'HJ', 'NS', 'SA', 'SS']; | ||
| var noForbiddenMiddleSection = !forbiddenMiddleSections.includes(plateSections[1]); // Rule 4: No license plate must be longer then 8 characters. | ||
|
|
||
| var validLength = "".concat(plateSections[0]).concat(plateSections[1]).concat(plateSections[2]).length <= 8; | ||
| return validFormat && validCountyCode && noForbiddenMiddleSection && validLength; | ||
| } | ||
| }; | ||
| function isLicensePlate(str, locale) { | ||
| assertString(str); | ||
|
|
||
| if (locale in validators$1) { | ||
| return validators$1[locale](str); | ||
| } else if (locale === 'any') { | ||
| for (var key in validators$1) { | ||
| // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes | ||
| // istanbul ignore else | ||
| if (validators$1.hasOwnProperty(key)) { | ||
| var validator = validators$1[key]; | ||
|
|
||
| if (validator(str)) { | ||
| return true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| throw new Error("Invalid locale '".concat(locale, "'")); | ||
| } | ||
|
|
||
| var version = '13.1.17'; | ||
| var validator = { | ||
| version: version, | ||
|
|
@@ -3168,7 +3209,8 @@ var validator = { | |
| toString: toString, | ||
| isSlug: isSlug, | ||
| isTaxID: isTaxID, | ||
| isDate: isDate | ||
| isDate: isDate, | ||
| isLicensePlate: isLicensePlate | ||
| }; | ||
|
|
||
| return validator; | ||
|
|
||
Large diffs are not rendered by default.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A regex to cover all these will be a little complex but can we try as opposed to listing manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do that!