chilean-plate-validator 0.5.3 → 0.6.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Gabriel Galilea
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Gabriel Galilea
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,23 +1,44 @@
1
- # chilean-plate-validator
2
-
3
- ## Description
4
-
5
- This module will help you to verify if a chilean registration plate is valid
6
-
7
- ## Code Example
8
-
9
- ```typescript
10
- import { plateValid } from 'chilean-plate-validator';
11
-
12
- plateValid('BBCC02');
13
- ```
14
-
15
- ## Installation
16
-
17
- ```shell
18
- npm i chilean-plate-validator --save
19
- ```
20
-
21
- ## License
22
-
23
- Read LICENCE.md
1
+ # chilean-plate-validator
2
+
3
+ ## Description
4
+
5
+ This module will help you to verify if a chilean registration plate is valid.
6
+
7
+ The RegExes built in code follows the chilean civil registration specifications.
8
+
9
+ [«Instructivo para Validación de Patentes - Servicio de Registro Civil e Identificación»](https://www.registrocivil.cl/PortalOI/Manuales/ValidacionPatentes.pdf)
10
+
11
+ ## Code Example
12
+
13
+ #### Example 1:
14
+ ```typescript
15
+ import { plateValid } from 'chilean-plate-validator';
16
+
17
+ plateValid('BBCC12'); // returns true
18
+ plateType('BBCC12'); // returns 'NEW_VEHICLE_PLATE'
19
+ ```
20
+
21
+ #### Example 2:
22
+ ```typescript
23
+ import { CLPlate } from 'chilean-plate-validator';
24
+
25
+ const plate = new CLPlate('BBCC12');
26
+
27
+ plate.valid // returns true
28
+ plate.type // returns 'NEW_VEHICLE_PLATE'
29
+ ```
30
+
31
+ ## Installation
32
+
33
+ ```shell
34
+ $ npm i chilean-plate-validator --save
35
+ ```
36
+
37
+ ## License
38
+
39
+ Read LICENCE.md
40
+
41
+ ## Author
42
+
43
+ - GitHub: [Gabo2151](https://github.com/gabo2151)
44
+ - Twitter: [gabriel_galilea](https://twitter.com/gabriel_galilea)
package/dist/index.d.ts CHANGED
@@ -1,32 +1,32 @@
1
- /**
2
- * Verifies if the plate is valid in Chile.
3
- *
4
- * @param plate Plate to validate.
5
- *
6
- * @returns True if the plate is valid in any of the RegEx saved,
7
- * false otherwise.
8
- */
9
- export declare function plateValid(plate: string): boolean;
10
- /**
11
- * Get the plate type according to the RegEx associated.
12
- *
13
- * @param plate Plate to check the type.
14
- *
15
- * @returns The type according to the RegEx that matches the plate submitted.
16
- */
17
- export declare function plateType(plate: string): string;
18
- /**
19
- * Plate class... Working on this...
20
- */
21
- export declare class Plate {
22
- validState: boolean;
23
- plateType: string;
24
- /**
25
- * Creates a new Plate instance.
26
- *
27
- * @param plate Plate required to check validity and type
28
- */
29
- constructor(plate: string);
30
- get valid(): boolean;
31
- get type(): string;
32
- }
1
+ /**
2
+ * Verifies if the plate is valid in Chile.
3
+ *
4
+ * @param plate Plate to validate.
5
+ *
6
+ * @returns True if the plate is valid in any of the RegEx saved,
7
+ * false otherwise.
8
+ */
9
+ export declare function plateValid(plate: string): boolean;
10
+ /**
11
+ * Get the plate type according to the RegEx associated.
12
+ *
13
+ * @param plate Plate to check the type.
14
+ *
15
+ * @returns The type according to the RegEx that matches the plate submitted.
16
+ */
17
+ export declare function plateType(plate: string): string;
18
+ /**
19
+ * Plate class... Working on this...
20
+ */
21
+ export declare class CLPlate {
22
+ private readonly validState;
23
+ private readonly plateType;
24
+ /**
25
+ * Creates a new Plate instance.
26
+ *
27
+ * @param plate Plate required to check validity and type
28
+ */
29
+ constructor(plate: string);
30
+ get valid(): boolean;
31
+ get type(): string;
32
+ }
package/dist/index.js CHANGED
@@ -1,80 +1,80 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Plate = exports.plateType = exports.plateValid = void 0;
4
- /**
5
- * RegExes build by chilean civil registration specifications.<br>
6
- * [«Instructivo para Validación de Patentes - Servicio de Registro Civil e Identificación»](https://www.registrocivil.cl/PortalOI/Manuales/ValidacionPatentes.pdf)
7
- */
8
- var REGEX_LIST = [
9
- { name: 'OLD_PLATE', regex: /^(?=.{6}$)[A-Z]{2}\d{4}[^s]*$/ },
10
- { name: 'NEW_VEHICLE_PLATE', regex: /^(?=.{6}$)[B-DF-HJ-LPR-TV-Z]{4}[1-9]\d[^s]*$/ },
11
- { name: 'NEW_MOTORCYCLE_PLATE', regex: /^(?=.{6}$)[B-DF-HJ-LPR-TV-Z]{3}\d{3}[^s]*$/ },
12
- ];
13
- /**
14
- * Verifies if the plate is valid in Chile.
15
- *
16
- * @param plate Plate to validate.
17
- *
18
- * @returns True if the plate is valid in any of the RegEx saved,
19
- * false otherwise.
20
- */
21
- function plateValid(plate) {
22
- var state = false;
23
- if (plate == null)
24
- return state;
25
- REGEX_LIST.forEach(function (reg) {
26
- if ("".concat(plate).match(reg.regex) != null)
27
- state = true;
28
- });
29
- return state;
30
- }
31
- exports.plateValid = plateValid;
32
- /**
33
- * Get the plate type according to the RegEx associated.
34
- *
35
- * @param plate Plate to check the type.
36
- *
37
- * @returns The type according to the RegEx that matches the plate submitted.
38
- */
39
- function plateType(plate) {
40
- var type = 'INVALID';
41
- if (plate == null)
42
- return type;
43
- REGEX_LIST.forEach(function (reg) {
44
- if ("".concat(plate).match(reg.regex) != null)
45
- type = reg.name;
46
- });
47
- return type;
48
- }
49
- exports.plateType = plateType;
50
- /**
51
- * Plate class... Working on this...
52
- */
53
- var Plate = /** @class */ (function () {
54
- /**
55
- * Creates a new Plate instance.
56
- *
57
- * @param plate Plate required to check validity and type
58
- */
59
- function Plate(plate) {
60
- this.validState = plateValid(plate);
61
- this.plateType = plateType(plate);
62
- }
63
- Object.defineProperty(Plate.prototype, "valid", {
64
- get: function () {
65
- return this.validState;
66
- },
67
- enumerable: false,
68
- configurable: true
69
- });
70
- Object.defineProperty(Plate.prototype, "type", {
71
- get: function () {
72
- return this.plateType;
73
- },
74
- enumerable: false,
75
- configurable: true
76
- });
77
- return Plate;
78
- }());
79
- exports.Plate = Plate;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CLPlate = exports.plateType = exports.plateValid = void 0;
4
+ /**
5
+ * RegExes build by chilean civil registration specifications.<br>
6
+ * [«Instructivo para Validación de Patentes - Servicio de Registro Civil e Identificación»](https://www.registrocivil.cl/PortalOI/Manuales/ValidacionPatentes.pdf)
7
+ */
8
+ var REGEX_LIST = [
9
+ { name: 'OLD_PLATE', regex: /^(?=.{6}$)[A-Z]{2}\d{4}[^s]*$/ },
10
+ { name: 'NEW_VEHICLE_PLATE', regex: /^(?=.{6}$)[B-DF-HJ-LPR-TV-Z]{4}[1-9]\d[^s]*$/ },
11
+ { name: 'NEW_MOTORCYCLE_PLATE', regex: /^(?=.{6}$)[B-DF-HJ-LPR-TV-Z]{3}\d{3}[^s]*$/ },
12
+ ];
13
+ /**
14
+ * Verifies if the plate is valid in Chile.
15
+ *
16
+ * @param plate Plate to validate.
17
+ *
18
+ * @returns True if the plate is valid in any of the RegEx saved,
19
+ * false otherwise.
20
+ */
21
+ function plateValid(plate) {
22
+ var state = false;
23
+ if (plate == null)
24
+ return state;
25
+ REGEX_LIST.forEach(function (reg) {
26
+ if (reg.regex.test("".concat(plate)))
27
+ state = true;
28
+ });
29
+ return state;
30
+ }
31
+ exports.plateValid = plateValid;
32
+ /**
33
+ * Get the plate type according to the RegEx associated.
34
+ *
35
+ * @param plate Plate to check the type.
36
+ *
37
+ * @returns The type according to the RegEx that matches the plate submitted.
38
+ */
39
+ function plateType(plate) {
40
+ var type = 'INVALID';
41
+ if (plate == null)
42
+ return type;
43
+ REGEX_LIST.forEach(function (reg) {
44
+ if (reg.regex.test("".concat(plate)))
45
+ type = reg.name;
46
+ });
47
+ return type;
48
+ }
49
+ exports.plateType = plateType;
50
+ /**
51
+ * Plate class... Working on this...
52
+ */
53
+ var CLPlate = /** @class */ (function () {
54
+ /**
55
+ * Creates a new Plate instance.
56
+ *
57
+ * @param plate Plate required to check validity and type
58
+ */
59
+ function CLPlate(plate) {
60
+ this.validState = plateValid(plate);
61
+ this.plateType = plateType(plate);
62
+ }
63
+ Object.defineProperty(CLPlate.prototype, "valid", {
64
+ get: function () {
65
+ return this.validState;
66
+ },
67
+ enumerable: false,
68
+ configurable: true
69
+ });
70
+ Object.defineProperty(CLPlate.prototype, "type", {
71
+ get: function () {
72
+ return this.plateType;
73
+ },
74
+ enumerable: false,
75
+ configurable: true
76
+ });
77
+ return CLPlate;
78
+ }());
79
+ exports.CLPlate = CLPlate;
80
80
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAM,UAAU,GAAG;IACjB,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,+BAA+B,EAAE;IAC7D,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,8CAA8C,EAAE;IACpF,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAE,4CAA4C,EAAE;CACtF,CAAA;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,KAAK,CAAC;IAChC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QACpB,IAAK,UAAG,KAAK,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI;YAAG,KAAK,GAAG,IAAI,CAAC;IAC1D,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI,IAAI,GAAG,SAAS,CAAC;IACrB,IAAI,KAA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CAAC;YAAG,KAAK,GAAG,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,gCAOC;AAED;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAa;IACrC,IAAI,IAAI,GAAG,SAAS,CAAC;IACrB,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/B,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QACpB,IAAK,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,UAAG,KAAK,CAAE,CAAC;YAAG,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;IACpD,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC;AAPD,8BAOC;AAED;;GAEG;AACH;IAIE;;;;OAIG;IACH,iBAAY,KAAa;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,sBAAI,0BAAK;aAAT;YACE,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;;;OAAA;IAED,sBAAI,yBAAI;aAAR;YACE,OAAO,IAAI,CAAC,SAAS,CAAC;QACxB,CAAC;;;OAAA;IAEH,cAAC;AAAD,CAAC,AAtBD,IAsBC;AAtBY,0BAAO"}
package/package.json CHANGED
@@ -1,28 +1,28 @@
1
- {
2
- "name": "chilean-plate-validator",
3
- "version": "0.5.3",
4
- "description": "Simple chilean plate validator",
5
- "author": "Gabriel Galilea",
6
- "license": "MIT License",
7
- "main": "dist/index.js",
8
- "typings": "dist/index.d.ts",
9
- "scripts": {
10
- "build": "tsc",
11
- "test": "echo \"Error: no test specified\" && exit 1"
12
- },
13
- "repository": {
14
- "type": "git",
15
- "url": "https://github.com/gabo2151/chilean-plate-validator"
16
- },
17
- "keywords": [
18
- "patente",
19
- "plate",
20
- "Chile",
21
- "validator",
22
- "validar"
23
- ],
24
- "dependencies": {},
25
- "devDependencies": {
26
- "typescript": "^4.7.4"
27
- }
28
- }
1
+ {
2
+ "name": "chilean-plate-validator",
3
+ "version": "0.6.0",
4
+ "description": "Simple chilean plate validator",
5
+ "author": "Gabriel Galilea",
6
+ "license": "MIT License",
7
+ "main": "dist/index.js",
8
+ "typings": "dist/index.d.ts",
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/gabo2151/chilean-plate-validator"
16
+ },
17
+ "keywords": [
18
+ "patente",
19
+ "plate",
20
+ "Chile",
21
+ "validator",
22
+ "validar"
23
+ ],
24
+ "dependencies": {},
25
+ "devDependencies": {
26
+ "typescript": "^4.7.4"
27
+ }
28
+ }