Skip to content

Commit

Permalink
Updating regex.json for current rules
Browse files Browse the repository at this point in the history
Updated regex rules based on updates to DL formats. Syncs up with actively maintained JavaScript version as seen at https://github.com/gas-buddy/usdl-regex/blob/master/regex.json with minor spacing to match current formatting.
  • Loading branch information
mbniebergall authored and Mark Niebergall committed Dec 4, 2019
1 parent 5ebdd25 commit 13c4334
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
27 changes: 16 additions & 11 deletions regex.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"AL": {
"rule": "^[0-9]{1,7}$",
"rule": "^[0-9]{1,8}$",
"description": [
"1-7 Numeric"
"1-8 Numeric"
]
},
"AK": {
Expand Down Expand Up @@ -145,9 +145,10 @@
]
},
"MA": {
"rule": "(^[A-Z]{1}[0-9]{8}$)|(^[0-9]{9}$)",
"rule": "(^[A-Z]{1}[0-9]{8}$)|(^[A-Z]{2}[0-9]{7}$)|(^[0-9]{9}$)",
"description": [
"1 Alpha + 8 Numeric",
"2 Alpha + 7 Numeric",
"9 Numeric"
]
},
Expand All @@ -171,13 +172,14 @@
]
},
"MO": {
"rule": "(^[A-Z]{1}[0-9]{5,9}$)|(^[A-Z]{1}[0-9]{6}[R]{1}$)|(^[0-9]{8}[A-Z]{2}$)|(^[0-9]{9}[A-Z]{1}$)|(^[0-9]{9}$)",
"rule": "(^[A-Z]{1}[0-9]{5,9}$)|(^[A-Z]{1}[0-9]{6}[R]{1}$)|(^[0-9]{3}[A-Z]{1}[0-9]{6}$)|(^[0-9]{8}[A-Z]{2}$)|(^[0-9]{9}[A-Z]{1}$)|(^[0-9]{9}$)",
"description": [
"1 Alpha + 5-9 Numeric",
"1 Alpha + 6 Numeric + 'R'",
"8 Numeric + 2 Alpha",
"9 Numeric + 1 Alpha",
"9 Numeric"
"9 Numeric",
"3 Numeric + 1 Alpha + 6 Numeric"
]
},
"MT": {
Expand All @@ -190,9 +192,10 @@
]
},
"NE": {
"rule": "^[0-9]{1,7}$",
"rule": "(^[0-9]{1,7}$)|(^[A-Z]{1}[0-9]{6,8}$)",
"description": [
"1-7 Numeric"
"1-7 Numeric",
"1 Alpha + 6-8 Numeric"
]
},
"NV": {
Expand Down Expand Up @@ -263,9 +266,11 @@
]
},
"OR": {
"rule": "^[0-9]{1,9}$",
"rule": "(^[0-9]{1,9}$)|(^[AB][0-9]{6}$)",
"description": [
"1-9 Numeric"
"1-9 Numeric",
"A + 6 Numeric",
"B + 6 Numeric"
]
},
"PA": {
Expand All @@ -282,9 +287,9 @@
]
},
"RI": {
"rule": "^([0-9]{7}$)|(^[A-Z]{1}[0-9]{6}$)",
"rule": "^([0-9]{7,8}$)|(^[A-Z]{1}[0-9]{6}$)",
"description": [
"7 Numeric",
"7-8 Numeric",
"1 Alpha + 6 Numeric"
]
},
Expand Down
22 changes: 19 additions & 3 deletions test/features/json.feature
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Feature: Valid Regex Rules
| AL | 12345 | TRUE |
| AL | 123456 | TRUE |
| AL | 1234567 | TRUE |
| AL | 12345678 | FALSE |
| AL | 12345678 | TRUE |
| AL | 123456789 | FALSE |
| AL | 123456A | FALSE |

| AK | 1 | TRUE |
Expand Down Expand Up @@ -224,6 +225,7 @@ Feature: Valid Regex Rules

| MA | A12345678 | TRUE |
| MA | AB12345678 | FALSE |
| MA | AB1234567 | TRUE |
| MA | A123456789 | FALSE |
| MA | A1234567 | FALSE |
| MA | 123456789 | TRUE |
Expand Down Expand Up @@ -279,6 +281,10 @@ Feature: Valid Regex Rules
| MO | 123456789 | TRUE |
| MO | 12345678 | FALSE |
| MO | 1234567890 | FALSE |
| MO | 123A123456 | TRUE |
| MO | 123AB23456 | FALSE |
| MO | 12A123456 | FALSE |
| MO | 123A1234567 | FALSE |

| MT | A12345678 | TRUE |
| MT | A1234567 | FALSE |
Expand Down Expand Up @@ -311,7 +317,9 @@ Feature: Valid Regex Rules
| NE | 123456 | TRUE |
| NE | 1234567 | TRUE |
| NE | 12345678 | FALSE |
| NE | A1234567 | FALSE |
| NE | A1234567 | TRUE |
| NE | A12345678 | TRUE |
| NE | A123456789 | FALSE |
| NE | 1234567A | FALSE |

| NV | 123456789 | TRUE |
Expand Down Expand Up @@ -456,6 +464,13 @@ Feature: Valid Regex Rules
| OR | 123456789A | FALSE |
| OR | A12345678 | FALSE |
| OR | 12345678A | FALSE |
| OR | A123456 | TRUE |
| OR | B123456 | TRUE |
| OR | C12345 | FALSE |
| OR | C123456 | FALSE |
| OR | C1234567 | FALSE |
| OR | A12345 | FALSE |
| OR | B1234567 | FALSE |

| PA | 12345678 | TRUE |
| PA | 1234567 | FALSE |
Expand All @@ -479,7 +494,8 @@ Feature: Valid Regex Rules

| RI | 1234567 | TRUE |
| RI | 123456 | FALSE |
| RI | 12345678 | FALSE |
| RI | 12345678 | TRUE |
| RI | 123456789 | FALSE |
| RI | A1234567 | FALSE |
| RI | 1234567A | FALSE |
| RI | A123456 | TRUE |
Expand Down

1 comment on commit 13c4334

@Akey1267
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please how can I get US DL numbers

Please sign in to comment.