Skip to content

Commit 83217ad

Browse files
committed
feat: initial multi-country validator + CLI + PHP variant
1 parent 6b6a4ec commit 83217ad

19 files changed

Lines changed: 933 additions & 55 deletions

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.eslintrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"env": {
3+
"es2022": true,
4+
"node": true
5+
},
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"ecmaVersion": "latest",
10+
"sourceType": "module"
11+
},
12+
"plugins": ["@typescript-eslint"],
13+
"rules": {
14+
"@typescript-eslint/no-unused-vars": ["warn", { "vars": "all", "args": "after-used", "ignoreRestSiblings": false }]
15+
}
16+
}

.gitattributes

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
# Auto detect text files and perform LF normalization
1+
# Auto LF normalization
22
* text=auto
3+
4+
# Treat TypeScript and JS as text
5+
*.ts text
6+
*.js text
7+
*.mjs text
8+
9+
# Mark generated files as linguist-vendored
10+
dist/* linguist-vendored

.github/workflows/test.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 20
20+
cache: "npm"
21+
22+
- name: Install deps
23+
run: npm ci
24+
25+
- name: Build
26+
run: npm run build
27+
28+
- name: Run tests
29+
run: npm test
30+
31+
- name: CLI smoke test
32+
run: node ./bin/cli.mjs "AB 123 CD" --countries IT --type car --pretty

.gitignore

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lib-cov
2222
# Coverage directory used by tools like istanbul
2323
coverage
2424
*.lcov
25-
25+
**_STASH**
2626
# nyc test coverage
2727
.nyc_output
2828

@@ -34,7 +34,7 @@ bower_components
3434

3535
# node-waf configuration
3636
.lock-wscript
37-
37+
*DS_Store
3838
# Compiled binary addons (https://nodejs.org/api/addons.html)
3939
build/Release
4040

@@ -134,3 +134,29 @@ dist
134134
.yarn/build-state.yml
135135
.yarn/install-state.gz
136136
.pnp.*
137+
# Node
138+
node_modules/
139+
dist/
140+
coverage/
141+
.nyc_output/
142+
143+
# IDE
144+
.vscode/
145+
.idea/
146+
*.swp
147+
*.swo
148+
149+
# Logs
150+
npm-debug.log*
151+
yarn-debug.log*
152+
yarn-error.log*
153+
pnpm-debug.log*
154+
*.log
155+
156+
# System
157+
.DS_Store
158+
Thumbs.db
159+
160+
# Env
161+
.env
162+
.env.*

.npmignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Build / output
2+
dist/
3+
node_modules/
4+
coverage/
5+
.nyc_output/
6+
7+
# Sources non necessari
8+
_php_variant/
9+
bin/
10+
**_STASH**
11+
scripts/
12+
**/*.test.ts
13+
**/*.spec.ts
14+
15+
# Config / system
16+
tsconfig.json
17+
tsconfig.*.json
18+
.eslintrc*
19+
.prettierrc*
20+
.jest*
21+
.vscode/
22+
.idea/
23+
24+
# Dotfiles che non servono su npm
25+
.git/
26+
.github/
27+
.gitattributes
28+
.gitignore
29+
30+
# Logs & cache
31+
npm-debug.log*
32+
yarn-debug.log*
33+
yarn-error.log*
34+
pnpm-debug.log*
35+
*.log
36+
.DS_Store
37+
38+
# Env & secrets
39+
.env
40+
.env.*
41+
.editorconfig

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"singleQuote": false,
4+
"trailingComma": "es5",
5+
"printWidth": 100
6+
}

README.md

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,148 @@
1-
# euro-plate-validator
2-
license-plate, validator, regex, europe, anpr, vehicle, car, nodejs, typescript, php, italy, germany, france, spain, uk, poland, netherlands, belgium, scandinavia, balkans, ukraine
1+
# 🌍 @codecorn/euro-plate-validator
2+
3+
> 🚗 European license plate validator (Russia excluded).
4+
> Multi-country regex-based syntax validation for EU/EEA license plates.
5+
> Supports Node.js (TypeScript/JavaScript) and PHP implementations.
6+
7+
[![@codecorn/euro-plate-validator](https://img.shields.io/badge/CODECORN-EURO--PLATE--VALIDATOR-green?style=for-the-badge&logo=vercel)](https://www.npmjs.com/package/@codecorn/euro-plate-validator)
8+
9+
[![Downloads](https://img.shields.io/npm/dt/@codecorn/euro-plate-validator?color=blue&label=npm%20downloads)](https://www.npmjs.com/package/@codecorn/euro-plate-validator)
10+
[![npm version](https://img.shields.io/npm/v/@codecorn/euro-plate-validator?color=brightgreen&logo=npm)](https://www.npmjs.com/package/@codecorn/euro-plate-validator)
11+
[![GitHub stars](https://img.shields.io/github/stars/CodeCornTech/euro-plate-validator?style=social)](https://github.com/CodeCornTech/euro-plate-validator)
12+
[![GitHub issues](https://img.shields.io/github/issues/CodeCornTech/euro-plate-validator?color=blue)](https://github.com/CodeCornTech/euro-plate-validator/issues)
13+
[![Tests](https://github.com/CodeCornTech/euro-plate-validator/actions/workflows/test.yml/badge.svg)](https://github.com/CodeCornTech/euro-plate-validator/actions/workflows/test.yml)
14+
[![MIT License](https://img.shields.io/github/license/CodeCornTech/euro-plate-validator)](LICENSE)
15+
16+
---
17+
18+
## ✨ Features
19+
20+
-**Multi-country support** (25+ EU/EEA countries)
21+
- 🚫 **Russia excluded** by design
22+
- 🔠 Normalizes input (spaces, hyphens)
23+
- 🖥 Available for **Node.js/TypeScript** and **PHP**
24+
- 📦 Ready to publish on **npm**
25+
26+
---
27+
28+
## 📦 Installation
29+
30+
### Node.js / TypeScript
31+
32+
```bash
33+
npm install @codecorn/euro-plate-validator
34+
```
35+
36+
### PHP
37+
38+
Scarica `EuroPlateValidator.php` nella tua codebase.
39+
40+
---
41+
42+
## 🚀 Usage
43+
44+
### Node.js / TypeScript
45+
46+
```ts
47+
import { validatePlate } from "@codecorn/euro-plate-validator";
48+
49+
// Italy
50+
console.log(validatePlate("AB 123 CD", ["IT"]));
51+
// -> { isValid: true, matches: [{country:"IT", name:"Italy"}], checked:["IT"] }
52+
53+
// UK
54+
console.log(validatePlate("AB12 CDE", ["UK", "IE"]));
55+
```
56+
57+
**Esempi veloci:**
58+
59+
```ts
60+
import { validatePlate } from "./dist/index.js";
61+
62+
validatePlate("AB 123 CD", ["IT"], { vehicleType: "car" }); // ✅ IT Car
63+
validatePlate("AA 12345", ["IT"], { vehicleType: "motorcycle" }); // ✅ IT Moto
64+
validatePlate("AA 12345", ["IT"], { vehicleType: "car" }); // ❌ (no_match)
65+
```
66+
67+
### PHP
68+
69+
```php
70+
require '_php_variant/EuroPlateValidator.php';
71+
72+
print_r(validate_plate("AB 123 CD", ["IT"], "car"));
73+
print_r(validate_plate("AA 12345", ["IT"], "motorcycle"));
74+
```
75+
76+
### 🔧 CLI
77+
78+
```bash
79+
npx @codecorn/euro-plate-validator "AB 123 CD" --countries IT,FR,DE --type car --pretty
80+
```
81+
82+
Opzioni:
83+
84+
- `--countries` / `-c`: lista di country code (comma-sep)
85+
- `--type` / `-t`: `car` | `motorcycle` | `any` (default: `any`)
86+
- `--pretty` / `-p`: output leggibile
87+
88+
Exit code: `0` se valido, `1` se non valido, `2` argomenti errati.
89+
90+
**Esempi CLI:**
91+
92+
```bash
93+
# Car IT
94+
npx euro-plate-validator "AB 123 CD" --countries IT --type car --pretty
95+
96+
# Moto IT
97+
npx euro-plate-validator "AA 12345" --countries IT --type motorcycle --pretty
98+
99+
# UK / IE
100+
npx euro-plate-validator "AB12 CDE" --countries UK,IE --type any
101+
```
102+
103+
---
104+
105+
## 🌍 Supported Countries
106+
107+
🇮🇹 IT | 🇬🇧 UK | 🇩🇪 DE | 🇫🇷 FR | 🇪🇸 ES | 🇵🇹 PT | 🇳🇱 NL | 🇧🇪 BE | 🇨🇭 CH | 🇦🇹 AT | 🇮🇪 IE | 🇱🇺 LU
108+
🇩🇰 DK | 🇸🇪 SE | 🇳🇴 NO | 🇫🇮 FI | 🇵🇱 PL | 🇨🇿 CZ | 🇸🇰 SK | 🇭🇺 HU | 🇷🇴 RO | 🇧🇬 BG | 🇸🇮 SI | 🇭🇷 HR | 🇬🇷 GR
109+
🇱🇹 LT | 🇱🇻 LV | 🇪🇪 EE | 🇺🇦 UA
110+
111+
---
112+
113+
## 📝 License
114+
115+
MIT © [CodeCorn™](https://codecorn.it)
116+
117+
Distribuito sotto licenza [MIT](LICENSE).
118+
119+
---
120+
121+
## 👤 Maintainer
122+
123+
<div style="display: flex; justify-content: space-between; align-items: center;">
124+
<div>
125+
<p><strong>👨‍💻 Federico Girolami</strong></p>
126+
<p><strong>Full Stack Developer</strong> | <strong>System Integrator</strong> | <strong>Digital Solution Architect</strong> 🚀</p>
127+
<p>📫 <strong>Get in Touch</strong></p>
128+
<p>🌐 <strong>Website</strong>: <a href="https://codecorn.it">codecorn.it</a> *(Under Construction)*</p>
129+
<p>📧 <strong>Email</strong>: <a href="mailto:f.girolami@codecorn.it">f.girolami@codecorn.it</a></p>
130+
<p>🐙 <strong>GitHub</strong>: <a href="https://github.com/fgirolami29">github.com/fgirolami29</a></p>
131+
</div>
132+
<div style="text-align: center;">
133+
<a href="https://www.codecorn.it">
134+
<img src="https://codecorn.it/wp-content/uploads/2025/05/CODECORN-trasp-qhite.png" alt="Code Corn Logo" width="250px" height="90px" style="margin-top:30px;margin-bottom:20px;"/>
135+
</a>
136+
<a href="https://github.com/fgirolami29">
137+
<img src="https://avatars.githubusercontent.com/u/68548715?s=200&v=4" alt="Federico Girolami Avatar" style="border-radius: 50%; width: 125px; height: 125px;border: 5px solid gold" />
138+
</a>
139+
</div>
140+
</div>
141+
142+
---
143+
144+
### 🤝 Contribute
145+
146+
Pull request benvenute. Per grosse modifiche apri una issue prima di iniziare.
147+
148+
> Powered by CodeCorn™ 🚀

0 commit comments

Comments
 (0)