@devix-tecnologia/value-objects 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{readme.md → README.md} +8 -1
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/placa_veiculo/index.js +113 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/index.d.ts.map +1 -1
- package/dist/cjs/types/placa_veiculo/index.d.ts +38 -0
- package/dist/cjs/types/placa_veiculo/index.d.ts.map +1 -0
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/placa_veiculo/index.js +112 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/placa_veiculo/index.d.ts +38 -0
- package/dist/esm/types/placa_veiculo/index.d.ts.map +1 -0
- package/package.json +14 -14
package/{readme.md → README.md}
RENAMED
|
@@ -33,11 +33,12 @@ import { ClassName } from '@devix-tecnologia/value-objects'
|
|
|
33
33
|
- [Phone](./src/telefone/readme.md): Manipulates and validates phone numbers, supporting Brazilian DDD and country codes.
|
|
34
34
|
- [CPF/CNPJ](./src/cpf_cnpj/readme.md): Validates and formats CPF and CNPJ documents.
|
|
35
35
|
- [Base64Image](./src/imagem_base64/readme.md): Manages and validates base64-encoded images, with automatic format detection.
|
|
36
|
+
- [Vehicle Plate](./src/placa_veiculo/readme.md): Validates and formats Brazilian vehicle plates, supporting both old (ABC1234) and Mercosul (ABC1D23) formats.
|
|
36
37
|
|
|
37
38
|
## Usage Examples
|
|
38
39
|
|
|
39
40
|
```typescript
|
|
40
|
-
import { Phone, CpfCnpj, Base64Image } from '@devix-tecnologia/value-objects'
|
|
41
|
+
import { Phone, CpfCnpj, Base64Image, PlacaVeiculo } from '@devix-tecnologia/value-objects'
|
|
41
42
|
|
|
42
43
|
// Phone
|
|
43
44
|
const tel = new Phone('+55 11 91234-5678')
|
|
@@ -53,6 +54,12 @@ console.log(doc.format()) // 123.456.789-09
|
|
|
53
54
|
const img = new Base64Image(base64String)
|
|
54
55
|
console.log(img.isValid()) // true
|
|
55
56
|
console.log(img.getFormat()) // 'png', 'jpeg', etc.
|
|
57
|
+
|
|
58
|
+
// Vehicle Plate
|
|
59
|
+
const plate = new PlacaVeiculo('ABC1234')
|
|
60
|
+
console.log(plate.isValid()) // true
|
|
61
|
+
console.log(plate.formatted) // ABC-1234
|
|
62
|
+
console.log(plate.format) // ANTIGA
|
|
56
63
|
```
|
|
57
64
|
|
|
58
65
|
## To Do
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImagemBase64 = exports.CpfCnpj = exports.Telefone = void 0;
|
|
3
|
+
exports.PlacaVeiculo = exports.ImagemBase64 = exports.CpfCnpj = exports.Telefone = void 0;
|
|
4
4
|
const index_js_1 = require("./telefone/index.js");
|
|
5
5
|
Object.defineProperty(exports, "Telefone", { enumerable: true, get: function () { return index_js_1.Telefone; } });
|
|
6
6
|
const index_js_2 = require("./cpf_cnpj/index.js");
|
|
7
7
|
Object.defineProperty(exports, "CpfCnpj", { enumerable: true, get: function () { return index_js_2.CpfCnpj; } });
|
|
8
8
|
const index_js_3 = require("./imagem_base64/index.js");
|
|
9
9
|
Object.defineProperty(exports, "ImagemBase64", { enumerable: true, get: function () { return index_js_3.ImagemBase64; } });
|
|
10
|
+
const index_js_4 = require("./placa_veiculo/index.js");
|
|
11
|
+
Object.defineProperty(exports, "PlacaVeiculo", { enumerable: true, get: function () { return index_js_4.PlacaVeiculo; } });
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlacaVeiculo = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Value Object para Placa de Veículo brasileira.
|
|
6
|
+
* Suporta dois formatos:
|
|
7
|
+
* - Formato Antigo: ABC1234 (3 letras + 4 números)
|
|
8
|
+
* - Formato Mercosul: ABC1D23 (3 letras + 1 número + 1 letra + 2 números)
|
|
9
|
+
*/
|
|
10
|
+
class PlacaVeiculo {
|
|
11
|
+
constructor(plate) {
|
|
12
|
+
this._isValid = false;
|
|
13
|
+
const normalized = this.normalizePlate(plate);
|
|
14
|
+
this._plate = normalized;
|
|
15
|
+
this._format = this.detectFormat(normalized);
|
|
16
|
+
this._isValid = this._format !== 'INVALID';
|
|
17
|
+
}
|
|
18
|
+
normalizePlate(plate) {
|
|
19
|
+
// Remove espaços, hífens e converte para maiúsculas
|
|
20
|
+
return plate.replace(/[\s\-]+/g, '').toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
detectFormat(plate) {
|
|
23
|
+
// Formato Antigo: ABC1234
|
|
24
|
+
const oldPattern = /^[A-Z]{3}\d{4}$/;
|
|
25
|
+
// Formato Mercosul: ABC1D23
|
|
26
|
+
const mercosulPattern = /^[A-Z]{3}\d[A-Z]\d{2}$/;
|
|
27
|
+
if (oldPattern.test(plate)) {
|
|
28
|
+
return 'ANTIGA';
|
|
29
|
+
}
|
|
30
|
+
if (mercosulPattern.test(plate)) {
|
|
31
|
+
// Verifica se a letra na 5ª posição não é I, O ou Q
|
|
32
|
+
const fifthChar = plate[4];
|
|
33
|
+
if (PlacaVeiculo.MERCOSUL_FORBIDDEN_LETTERS.includes(fifthChar)) {
|
|
34
|
+
return 'INVALID';
|
|
35
|
+
}
|
|
36
|
+
return 'MERCOSUL';
|
|
37
|
+
}
|
|
38
|
+
return 'INVALID';
|
|
39
|
+
}
|
|
40
|
+
get type() {
|
|
41
|
+
return 'VEHICLE_PLATE';
|
|
42
|
+
}
|
|
43
|
+
get version() {
|
|
44
|
+
return PlacaVeiculo.VERSION;
|
|
45
|
+
}
|
|
46
|
+
get validation() {
|
|
47
|
+
return 'Validação de formato de placa brasileira (Antiga e Mercosul)';
|
|
48
|
+
}
|
|
49
|
+
get format() {
|
|
50
|
+
return this._format;
|
|
51
|
+
}
|
|
52
|
+
get formatted() {
|
|
53
|
+
this.isValid({ raiseException: true });
|
|
54
|
+
if (this._format === 'ANTIGA') {
|
|
55
|
+
// ABC-1234
|
|
56
|
+
return `${this._plate.slice(0, 3)}-${this._plate.slice(3)}`;
|
|
57
|
+
}
|
|
58
|
+
// ABC1D23 -> ABC-1D23
|
|
59
|
+
return `${this._plate.slice(0, 3)}-${this._plate.slice(3)}`;
|
|
60
|
+
}
|
|
61
|
+
get unformatted() {
|
|
62
|
+
this.isValid({ raiseException: true });
|
|
63
|
+
return this._plate;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
type: this.type,
|
|
68
|
+
value: this.unformatted,
|
|
69
|
+
formatted: this.formatted,
|
|
70
|
+
format: this.format,
|
|
71
|
+
isValid: this._isValid,
|
|
72
|
+
version: this.version,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
toString() {
|
|
76
|
+
return this.formatted;
|
|
77
|
+
}
|
|
78
|
+
isValid(config = { raiseException: false }) {
|
|
79
|
+
if (config.raiseException && !this._isValid) {
|
|
80
|
+
throw new Error('Invalid vehicle plate');
|
|
81
|
+
}
|
|
82
|
+
return this._isValid;
|
|
83
|
+
}
|
|
84
|
+
equals(other) {
|
|
85
|
+
if (!this._isValid)
|
|
86
|
+
return false;
|
|
87
|
+
try {
|
|
88
|
+
const otherPlate = other instanceof PlacaVeiculo
|
|
89
|
+
? other
|
|
90
|
+
: new PlacaVeiculo(other);
|
|
91
|
+
return this.unformatted === otherPlate.unformatted;
|
|
92
|
+
}
|
|
93
|
+
catch (_a) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Verifica se a placa está no formato Mercosul
|
|
99
|
+
*/
|
|
100
|
+
isMercosul() {
|
|
101
|
+
return this._format === 'MERCOSUL';
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Verifica se a placa está no formato antigo
|
|
105
|
+
*/
|
|
106
|
+
isOldFormat() {
|
|
107
|
+
return this._format === 'ANTIGA';
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.PlacaVeiculo = PlacaVeiculo;
|
|
111
|
+
PlacaVeiculo.VERSION = '1.0.0';
|
|
112
|
+
// Letras não permitidas no padrão Mercosul na 5ª posição
|
|
113
|
+
PlacaVeiculo.MERCOSUL_FORBIDDEN_LETTERS = ['I', 'O', 'Q'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Telefone } from './telefone/index.js';
|
|
2
2
|
import { CpfCnpj } from './cpf_cnpj/index.js';
|
|
3
3
|
import { ImagemBase64 } from './imagem_base64/index.js';
|
|
4
|
-
|
|
4
|
+
import { PlacaVeiculo } from './placa_veiculo/index.js';
|
|
5
|
+
export { Telefone, CpfCnpj, ImagemBase64, PlacaVeiculo };
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IBaseClassText, ValidConfig } from '../types/base_class.js';
|
|
2
|
+
type PlateFormat = 'ANTIGA' | 'MERCOSUL' | 'INVALID';
|
|
3
|
+
/**
|
|
4
|
+
* Value Object para Placa de Veículo brasileira.
|
|
5
|
+
* Suporta dois formatos:
|
|
6
|
+
* - Formato Antigo: ABC1234 (3 letras + 4 números)
|
|
7
|
+
* - Formato Mercosul: ABC1D23 (3 letras + 1 número + 1 letra + 2 números)
|
|
8
|
+
*/
|
|
9
|
+
declare class PlacaVeiculo implements IBaseClassText {
|
|
10
|
+
private _plate;
|
|
11
|
+
private _format;
|
|
12
|
+
private _isValid;
|
|
13
|
+
private static readonly VERSION;
|
|
14
|
+
private static readonly MERCOSUL_FORBIDDEN_LETTERS;
|
|
15
|
+
constructor(plate: string);
|
|
16
|
+
private normalizePlate;
|
|
17
|
+
private detectFormat;
|
|
18
|
+
get type(): string;
|
|
19
|
+
get version(): string;
|
|
20
|
+
get validation(): string;
|
|
21
|
+
get format(): PlateFormat;
|
|
22
|
+
get formatted(): string;
|
|
23
|
+
get unformatted(): string;
|
|
24
|
+
toJSON(): object;
|
|
25
|
+
toString(): string;
|
|
26
|
+
isValid(config?: ValidConfig): boolean;
|
|
27
|
+
equals(other: PlacaVeiculo | unknown): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Verifica se a placa está no formato Mercosul
|
|
30
|
+
*/
|
|
31
|
+
isMercosul(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Verifica se a placa está no formato antigo
|
|
34
|
+
*/
|
|
35
|
+
isOldFormat(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export { PlacaVeiculo, type PlateFormat };
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAGzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAkB;gBAExD,KAAK,EAAE,MAAM;IAOzB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;IAsBpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,SAAS,IAAI,MAAM,CAUtB;IAED,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,MAAM,IAAI,MAAM;IAWhB,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO;IAOjE,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO;IAc9C;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,CAAA"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Telefone } from './telefone/index.js';
|
|
2
2
|
import { CpfCnpj } from './cpf_cnpj/index.js';
|
|
3
3
|
import { ImagemBase64 } from './imagem_base64/index.js';
|
|
4
|
-
|
|
4
|
+
import { PlacaVeiculo } from './placa_veiculo/index.js';
|
|
5
|
+
export { Telefone, CpfCnpj, ImagemBase64, PlacaVeiculo };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value Object para Placa de Veículo brasileira.
|
|
3
|
+
* Suporta dois formatos:
|
|
4
|
+
* - Formato Antigo: ABC1234 (3 letras + 4 números)
|
|
5
|
+
* - Formato Mercosul: ABC1D23 (3 letras + 1 número + 1 letra + 2 números)
|
|
6
|
+
*/
|
|
7
|
+
class PlacaVeiculo {
|
|
8
|
+
_plate;
|
|
9
|
+
_format;
|
|
10
|
+
_isValid = false;
|
|
11
|
+
static VERSION = '1.0.0';
|
|
12
|
+
// Letras não permitidas no padrão Mercosul na 5ª posição
|
|
13
|
+
static MERCOSUL_FORBIDDEN_LETTERS = ['I', 'O', 'Q'];
|
|
14
|
+
constructor(plate) {
|
|
15
|
+
const normalized = this.normalizePlate(plate);
|
|
16
|
+
this._plate = normalized;
|
|
17
|
+
this._format = this.detectFormat(normalized);
|
|
18
|
+
this._isValid = this._format !== 'INVALID';
|
|
19
|
+
}
|
|
20
|
+
normalizePlate(plate) {
|
|
21
|
+
// Remove espaços, hífens e converte para maiúsculas
|
|
22
|
+
return plate.replace(/[\s\-]+/g, '').toUpperCase();
|
|
23
|
+
}
|
|
24
|
+
detectFormat(plate) {
|
|
25
|
+
// Formato Antigo: ABC1234
|
|
26
|
+
const oldPattern = /^[A-Z]{3}\d{4}$/;
|
|
27
|
+
// Formato Mercosul: ABC1D23
|
|
28
|
+
const mercosulPattern = /^[A-Z]{3}\d[A-Z]\d{2}$/;
|
|
29
|
+
if (oldPattern.test(plate)) {
|
|
30
|
+
return 'ANTIGA';
|
|
31
|
+
}
|
|
32
|
+
if (mercosulPattern.test(plate)) {
|
|
33
|
+
// Verifica se a letra na 5ª posição não é I, O ou Q
|
|
34
|
+
const fifthChar = plate[4];
|
|
35
|
+
if (PlacaVeiculo.MERCOSUL_FORBIDDEN_LETTERS.includes(fifthChar)) {
|
|
36
|
+
return 'INVALID';
|
|
37
|
+
}
|
|
38
|
+
return 'MERCOSUL';
|
|
39
|
+
}
|
|
40
|
+
return 'INVALID';
|
|
41
|
+
}
|
|
42
|
+
get type() {
|
|
43
|
+
return 'VEHICLE_PLATE';
|
|
44
|
+
}
|
|
45
|
+
get version() {
|
|
46
|
+
return PlacaVeiculo.VERSION;
|
|
47
|
+
}
|
|
48
|
+
get validation() {
|
|
49
|
+
return 'Validação de formato de placa brasileira (Antiga e Mercosul)';
|
|
50
|
+
}
|
|
51
|
+
get format() {
|
|
52
|
+
return this._format;
|
|
53
|
+
}
|
|
54
|
+
get formatted() {
|
|
55
|
+
this.isValid({ raiseException: true });
|
|
56
|
+
if (this._format === 'ANTIGA') {
|
|
57
|
+
// ABC-1234
|
|
58
|
+
return `${this._plate.slice(0, 3)}-${this._plate.slice(3)}`;
|
|
59
|
+
}
|
|
60
|
+
// ABC1D23 -> ABC-1D23
|
|
61
|
+
return `${this._plate.slice(0, 3)}-${this._plate.slice(3)}`;
|
|
62
|
+
}
|
|
63
|
+
get unformatted() {
|
|
64
|
+
this.isValid({ raiseException: true });
|
|
65
|
+
return this._plate;
|
|
66
|
+
}
|
|
67
|
+
toJSON() {
|
|
68
|
+
return {
|
|
69
|
+
type: this.type,
|
|
70
|
+
value: this.unformatted,
|
|
71
|
+
formatted: this.formatted,
|
|
72
|
+
format: this.format,
|
|
73
|
+
isValid: this._isValid,
|
|
74
|
+
version: this.version,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
toString() {
|
|
78
|
+
return this.formatted;
|
|
79
|
+
}
|
|
80
|
+
isValid(config = { raiseException: false }) {
|
|
81
|
+
if (config.raiseException && !this._isValid) {
|
|
82
|
+
throw new Error('Invalid vehicle plate');
|
|
83
|
+
}
|
|
84
|
+
return this._isValid;
|
|
85
|
+
}
|
|
86
|
+
equals(other) {
|
|
87
|
+
if (!this._isValid)
|
|
88
|
+
return false;
|
|
89
|
+
try {
|
|
90
|
+
const otherPlate = other instanceof PlacaVeiculo
|
|
91
|
+
? other
|
|
92
|
+
: new PlacaVeiculo(other);
|
|
93
|
+
return this.unformatted === otherPlate.unformatted;
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Verifica se a placa está no formato Mercosul
|
|
101
|
+
*/
|
|
102
|
+
isMercosul() {
|
|
103
|
+
return this._format === 'MERCOSUL';
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Verifica se a placa está no formato antigo
|
|
107
|
+
*/
|
|
108
|
+
isOldFormat() {
|
|
109
|
+
return this._format === 'ANTIGA';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export { PlacaVeiculo };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Telefone } from './telefone/index.js';
|
|
2
2
|
import { CpfCnpj } from './cpf_cnpj/index.js';
|
|
3
3
|
import { ImagemBase64 } from './imagem_base64/index.js';
|
|
4
|
-
|
|
4
|
+
import { PlacaVeiculo } from './placa_veiculo/index.js';
|
|
5
|
+
export { Telefone, CpfCnpj, ImagemBase64, PlacaVeiculo };
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEvD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IBaseClassText, ValidConfig } from '../types/base_class.js';
|
|
2
|
+
type PlateFormat = 'ANTIGA' | 'MERCOSUL' | 'INVALID';
|
|
3
|
+
/**
|
|
4
|
+
* Value Object para Placa de Veículo brasileira.
|
|
5
|
+
* Suporta dois formatos:
|
|
6
|
+
* - Formato Antigo: ABC1234 (3 letras + 4 números)
|
|
7
|
+
* - Formato Mercosul: ABC1D23 (3 letras + 1 número + 1 letra + 2 números)
|
|
8
|
+
*/
|
|
9
|
+
declare class PlacaVeiculo implements IBaseClassText {
|
|
10
|
+
private _plate;
|
|
11
|
+
private _format;
|
|
12
|
+
private _isValid;
|
|
13
|
+
private static readonly VERSION;
|
|
14
|
+
private static readonly MERCOSUL_FORBIDDEN_LETTERS;
|
|
15
|
+
constructor(plate: string);
|
|
16
|
+
private normalizePlate;
|
|
17
|
+
private detectFormat;
|
|
18
|
+
get type(): string;
|
|
19
|
+
get version(): string;
|
|
20
|
+
get validation(): string;
|
|
21
|
+
get format(): PlateFormat;
|
|
22
|
+
get formatted(): string;
|
|
23
|
+
get unformatted(): string;
|
|
24
|
+
toJSON(): object;
|
|
25
|
+
toString(): string;
|
|
26
|
+
isValid(config?: ValidConfig): boolean;
|
|
27
|
+
equals(other: PlacaVeiculo | unknown): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Verifica se a placa está no formato Mercosul
|
|
30
|
+
*/
|
|
31
|
+
isMercosul(): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Verifica se a placa está no formato antigo
|
|
34
|
+
*/
|
|
35
|
+
isOldFormat(): boolean;
|
|
36
|
+
}
|
|
37
|
+
export { PlacaVeiculo, type PlateFormat };
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/placa_veiculo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpE,KAAK,WAAW,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAA;AAEpD;;;;;GAKG;AACH,cAAM,YAAa,YAAW,cAAc;IAC1C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAU;IAGzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAkB;gBAExD,KAAK,EAAE,MAAM;IAOzB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;IAsBpB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,WAAW,CAExB;IAED,IAAI,SAAS,IAAI,MAAM,CAUtB;IAED,IAAI,WAAW,IAAI,MAAM,CAGxB;IAED,MAAM,IAAI,MAAM;IAWhB,QAAQ,IAAI,MAAM;IAIlB,OAAO,CAAC,MAAM,GAAE,WAAuC,GAAG,OAAO;IAOjE,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,GAAG,OAAO;IAc9C;;OAEG;IACH,UAAU,IAAI,OAAO;IAIrB;;OAEG;IACH,WAAW,IAAI,OAAO;CAGvB;AAED,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devix-tecnologia/value-objects",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Coleção de objetos de valores para implementação em sistemas.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,23 +37,23 @@
|
|
|
37
37
|
"author": "Roberto Seba@Devix Tecnologia 2023",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@eslint/js": "^9.
|
|
40
|
+
"@eslint/js": "^9.37.0",
|
|
41
41
|
"@semantic-release/git": "^10.0.1",
|
|
42
|
-
"@semantic-release/github": "^
|
|
43
|
-
"@semantic-release/npm": "^
|
|
44
|
-
"@types/node": "^
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
46
|
-
"@typescript-eslint/parser": "^8.
|
|
42
|
+
"@semantic-release/github": "^12.0.0",
|
|
43
|
+
"@semantic-release/npm": "^13.0.0",
|
|
44
|
+
"@types/node": "^24.7.2",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
46
|
+
"@typescript-eslint/parser": "^8.46.1",
|
|
47
47
|
"@vitest/ui": "^3.2.4",
|
|
48
48
|
"assert": "^2.1.0",
|
|
49
|
-
"eslint": "^9.
|
|
50
|
-
"eslint-config-prettier": "^10.
|
|
51
|
-
"eslint-plugin-prettier": "^5.
|
|
52
|
-
"prettier": "^3.
|
|
53
|
-
"semantic-release": "^24.2.
|
|
49
|
+
"eslint": "^9.37.0",
|
|
50
|
+
"eslint-config-prettier": "^10.1.8",
|
|
51
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
52
|
+
"prettier": "^3.6.2",
|
|
53
|
+
"semantic-release": "^24.2.9",
|
|
54
54
|
"ts-node": "^10.9.2",
|
|
55
|
-
"tsx": "^4.
|
|
56
|
-
"typescript": "^5.
|
|
55
|
+
"tsx": "^4.20.6",
|
|
56
|
+
"typescript": "^5.9.3",
|
|
57
57
|
"vitest": "^3.2.4"
|
|
58
58
|
},
|
|
59
59
|
"exports": {
|