@caucasus/az-utils 0.2.3 → 0.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 CHANGED
@@ -2,7 +2,6 @@
2
2
  ![npm version](https://img.shields.io/npm/v/@caucasus/az-utils)
3
3
  ![license](https://img.shields.io/npm/l/@caucasus/az-utils)
4
4
 
5
-
6
5
  # az-utils 🇦🇿
7
6
 
8
7
  A lightweight, TypeScript-first utility library providing **Azerbaijan-specific helpers** commonly needed in backend development.
@@ -10,6 +9,7 @@ A lightweight, TypeScript-first utility library providing **Azerbaijan-specific
10
9
  This package focuses on **validation, normalization, and parsing** of data formats frequently used in Azerbaijan-based systems.
11
10
 
12
11
  > Initial release focuses on **Azerbaijan mobile phone utilities**
12
+ > Added support for **FIN and local ID utilities**
13
13
 
14
14
  ---
15
15
 
@@ -21,7 +21,18 @@ This package focuses on **validation, normalization, and parsing** of data forma
21
21
  - Normalize phone numbers to a standard local format
22
22
  - Detect mobile operator (Azercell, Bakcell, Nar)
23
23
 
24
- More utilities (FIN, IBAN, passport, addresses) will be added incrementally.
24
+ ### 📱 FIN Utilities
25
+
26
+ - Validate FIN
27
+ - Normalize FIN
28
+
29
+ ### 📱 Passport Utilities
30
+
31
+ - Validate local ID series
32
+ - Normalize ID series
33
+ - Supported series (AZE,AA,AB)
34
+
35
+ More utilities (IBAN, addresses) will be added incrementally.
25
36
 
26
37
  ---
27
38
 
@@ -41,6 +52,7 @@ import {
41
52
  getAzMobileOperator,
42
53
  IsAzPhone,
43
54
  TransformAzPhone
55
+ ...etc
44
56
  } from "az-utils";
45
57
 
46
58
  ```
@@ -52,7 +64,9 @@ isValidAzPhone("+994 (50) 123-45-67"); // true
52
64
  isValidAzPhone("0501234567"); // true
53
65
  isValidAzPhone("0401234567"); // false
54
66
  ```
67
+
55
68
  Supported input formats:
69
+
56
70
  - 0501234567
57
71
  - 050 123 45 67
58
72
  - (050) 123-45-67
@@ -90,29 +104,37 @@ getAzMobileOperator("0771234567");
90
104
  class TestDto {
91
105
  @IsAzPhone()
92
106
  phone!: string;
107
+
108
+ @IsFin()
109
+ fin!: string
110
+
111
+ @IsSeries()
112
+ idSeries!: string
93
113
  }
94
114
  ```
95
115
 
96
116
  ### Supported Prefixes
97
117
 
118
+ ## Mobile phones
119
+
98
120
  | Prefix | Operator |
99
- | -------- | -------- |
121
+ | ------------ | -------- |
100
122
  | 050, 051,010 | Azercell |
101
123
  | 055, 099 | Bakcell |
102
124
  | 070, 077 | Nar |
103
125
 
126
+ ## Local ID series
104
127
 
128
+ AZE, AA, AB
105
129
 
106
- ## 🛣 Roadmap
130
+ ---
107
131
 
108
- Planned additions:
132
+ ## 🛣 Roadmap
109
133
 
110
- - FIN (Fərdi İdentifikasiya Nömrəsi) validation
134
+ Planned additions:
111
135
 
112
136
  - Azerbaijan IBAN validation
113
137
 
114
- - Passport series validation
115
-
116
138
  - Address parsing utilities
117
139
 
118
140
  - Localization helpers (AZ / EN / RU)
@@ -129,9 +151,8 @@ Please:
129
151
 
130
152
  - Avoid breaking changes without discussion
131
153
 
132
- ## 📄 License
154
+ ## 📄 License
133
155
 
134
156
  MIT License © Contributors
135
157
 
136
- ---
137
-
158
+ ---
@@ -0,0 +1,2 @@
1
+ export { IsFin } from "./isFin.decorator";
2
+ export { TransformFin } from "./transform-fin.decorators";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformFin = exports.IsFin = void 0;
4
+ var isFin_decorator_1 = require("./isFin.decorator");
5
+ Object.defineProperty(exports, "IsFin", { enumerable: true, get: function () { return isFin_decorator_1.IsFin; } });
6
+ var transform_fin_decorators_1 = require("./transform-fin.decorators");
7
+ Object.defineProperty(exports, "TransformFin", { enumerable: true, get: function () { return transform_fin_decorators_1.TransformFin; } });
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from "class-validator";
2
+ export declare function IsFin(validationOptions?: ValidationOptions): PropertyDecorator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsFin = IsFin;
4
+ const class_validator_1 = require("class-validator");
5
+ const isValidFin_1 = require("../isValidFin");
6
+ function IsFin(validationOptions) {
7
+ return function (target, propertyKey) {
8
+ (0, class_validator_1.registerDecorator)({
9
+ name: "IsFin",
10
+ target: target.constructor,
11
+ propertyName: propertyKey,
12
+ options: validationOptions,
13
+ validator: {
14
+ validate(value) {
15
+ return typeof value === "string" && (0, isValidFin_1.isValidFin)(value);
16
+ },
17
+ defaultMessage() {
18
+ return "$property must be a valid Azerbaijan FIN";
19
+ },
20
+ },
21
+ });
22
+ };
23
+ }
@@ -0,0 +1 @@
1
+ export declare function TransformFin(): PropertyDecorator;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformFin = TransformFin;
4
+ const class_transformer_1 = require("class-transformer");
5
+ const normalizeFin_1 = require("../normalizeFin");
6
+ function TransformFin() {
7
+ return (0, class_transformer_1.Transform)(({ value }) => {
8
+ if (value === undefined || value === null)
9
+ return value;
10
+ if (typeof value !== "string")
11
+ return value;
12
+ return (0, normalizeFin_1.normalizeFin)(value);
13
+ });
14
+ }
@@ -1 +1,3 @@
1
- export {};
1
+ export { isValidFin } from "./isValidFin";
2
+ export { normalizeFin } from "./normalizeFin";
3
+ export * from "./decorators";
package/dist/fin/index.js CHANGED
@@ -1,2 +1,22 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.normalizeFin = exports.isValidFin = void 0;
18
+ var isValidFin_1 = require("./isValidFin");
19
+ Object.defineProperty(exports, "isValidFin", { enumerable: true, get: function () { return isValidFin_1.isValidFin; } });
20
+ var normalizeFin_1 = require("./normalizeFin");
21
+ Object.defineProperty(exports, "normalizeFin", { enumerable: true, get: function () { return normalizeFin_1.normalizeFin; } });
22
+ __exportStar(require("./decorators"), exports);
@@ -0,0 +1 @@
1
+ export declare function isValidFin(fin: string): boolean;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidFin = isValidFin;
4
+ function isValidFin(fin) {
5
+ if (typeof fin !== "string")
6
+ return false;
7
+ return /^[A-Z0-9]{7}$/.test(fin.toUpperCase());
8
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeFin(fin: string): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeFin = normalizeFin;
4
+ function normalizeFin(fin) {
5
+ if (typeof fin !== "string")
6
+ return fin;
7
+ return fin.toUpperCase();
8
+ }
package/dist/index.d.ts CHANGED
@@ -1 +1,3 @@
1
1
  export * from "./phone";
2
+ export * from "./fin";
3
+ export * from "./passport";
package/dist/index.js CHANGED
@@ -15,3 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./phone"), exports);
18
+ __exportStar(require("./fin"), exports);
19
+ __exportStar(require("./passport"), exports);
@@ -0,0 +1 @@
1
+ export declare const SERIES_REGEX: RegExp;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SERIES_REGEX = void 0;
4
+ exports.SERIES_REGEX = /^(AZE\d{8}|AA\d{7}|AB\d{7})$/;
@@ -0,0 +1,2 @@
1
+ export { IsSeries } from "./isSeries.decorator";
2
+ export { TransformSeries } from "./transformSeries.decorator";
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformSeries = exports.IsSeries = void 0;
4
+ var isSeries_decorator_1 = require("./isSeries.decorator");
5
+ Object.defineProperty(exports, "IsSeries", { enumerable: true, get: function () { return isSeries_decorator_1.IsSeries; } });
6
+ var transformSeries_decorator_1 = require("./transformSeries.decorator");
7
+ Object.defineProperty(exports, "TransformSeries", { enumerable: true, get: function () { return transformSeries_decorator_1.TransformSeries; } });
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from "class-validator";
2
+ export declare function IsSeries(validationOptions?: ValidationOptions): PropertyDecorator;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsSeries = IsSeries;
4
+ const class_validator_1 = require("class-validator");
5
+ const isValidSeries_1 = require("../isValidSeries");
6
+ function IsSeries(validationOptions) {
7
+ return function (target, propertyKey) {
8
+ (0, class_validator_1.registerDecorator)({
9
+ name: "IsSeries",
10
+ target: target.constructor,
11
+ propertyName: propertyKey,
12
+ options: validationOptions,
13
+ validator: {
14
+ validate(value) {
15
+ return typeof value === "string" && (0, isValidSeries_1.isValidSeries)(value);
16
+ },
17
+ defaultMessage() {
18
+ return "$property must be a valid Azerbaijan series";
19
+ },
20
+ },
21
+ });
22
+ };
23
+ }
@@ -0,0 +1 @@
1
+ export declare function TransformSeries(): PropertyDecorator;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransformSeries = TransformSeries;
4
+ const class_transformer_1 = require("class-transformer");
5
+ const normalizeSeries_1 = require("../normalizeSeries");
6
+ function TransformSeries() {
7
+ return (0, class_transformer_1.Transform)(({ value }) => {
8
+ if (value === undefined || value === null)
9
+ return value;
10
+ if (typeof value !== "string")
11
+ return value;
12
+ return (0, normalizeSeries_1.normalizeSeries)(value);
13
+ });
14
+ }
@@ -1 +1,3 @@
1
- export {};
1
+ export { isValidSeries } from "./isValidSeries";
2
+ export { normalizeSeries } from "./normalizeSeries";
3
+ export * from "./decorators";
@@ -1,2 +1,22 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.normalizeSeries = exports.isValidSeries = void 0;
18
+ var isValidSeries_1 = require("./isValidSeries");
19
+ Object.defineProperty(exports, "isValidSeries", { enumerable: true, get: function () { return isValidSeries_1.isValidSeries; } });
20
+ var normalizeSeries_1 = require("./normalizeSeries");
21
+ Object.defineProperty(exports, "normalizeSeries", { enumerable: true, get: function () { return normalizeSeries_1.normalizeSeries; } });
22
+ __exportStar(require("./decorators"), exports);
@@ -0,0 +1 @@
1
+ export declare function isValidSeries(series: string): boolean;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isValidSeries = isValidSeries;
4
+ const constants_1 = require("./constants");
5
+ function isValidSeries(series) {
6
+ if (typeof series !== "string")
7
+ return false;
8
+ return constants_1.SERIES_REGEX.test(series.toUpperCase());
9
+ }
@@ -0,0 +1 @@
1
+ export declare function normalizeSeries(series: string): string;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeSeries = normalizeSeries;
4
+ function normalizeSeries(series) {
5
+ if (typeof series !== "string")
6
+ return series;
7
+ return series.toUpperCase().trim();
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caucasus/az-utils",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "Azerbaijan-specific utility functions for Node.js backends",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",