@thisisagile/easy-domain 17.20.7 → 17.21.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/dist/index.mjs CHANGED
@@ -16,4 +16,5 @@ export * from "./values/DunsNumber";
16
16
  export * from "./values/PostalCode";
17
17
  export * from "./values/Slug";
18
18
  export * from "./values/Url";
19
+ export * from "./values/VAT";
19
20
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './enums/Country';\nexport * from './enums/Currency';\nexport * from './enums/Locale';\nexport * from './enums/UnitOfMeasurement';\nexport * from './enums/UnitOfWeight';\n\nexport * from './structs/Address';\nexport * from './structs/Box';\nexport * from './structs/Dimension';\nexport * from './structs/Money';\nexport * from './structs/Name';\nexport * from './structs/Weight';\n\nexport * from './values/EAN';\nexport * from './values/Email';\nexport * from './values/IBAN';\nexport * from './values/DunsNumber';\nexport * from './values/PostalCode';\nexport * from './values/Slug';\nexport * from './values/Url';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from './enums/Country';\nexport * from './enums/Currency';\nexport * from './enums/Locale';\nexport * from './enums/UnitOfMeasurement';\nexport * from './enums/UnitOfWeight';\n\nexport * from './structs/Address';\nexport * from './structs/Box';\nexport * from './structs/Dimension';\nexport * from './structs/Money';\nexport * from './structs/Name';\nexport * from './structs/Weight';\n\nexport * from './values/EAN';\nexport * from './values/Email';\nexport * from './values/IBAN';\nexport * from './values/DunsNumber';\nexport * from './values/PostalCode';\nexport * from './values/Slug';\nexport * from './values/Url';\nexport * from './values/VAT';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { Value } from '@thisisagile/easy';
2
+ export declare class VAT extends Value {
3
+ private readonly country;
4
+ constructor(vat: unknown, country?: string);
5
+ get isValid(): boolean;
6
+ }
7
+ export declare const vat: (v: unknown, country?: string) => VAT;
@@ -0,0 +1,29 @@
1
+ import {
2
+ require_validator
3
+ } from "../chunk-CF2KLUD7.mjs";
4
+ import {
5
+ __toESM
6
+ } from "../chunk-RDITZTSA.mjs";
7
+
8
+ // src/values/VAT.ts
9
+ var import_validator = __toESM(require_validator());
10
+ import { isNotEmpty, text, Value } from "@thisisagile/easy";
11
+ var VAT = class extends Value {
12
+ country;
13
+ constructor(vat2, country = "NL") {
14
+ const cleaned = text(vat2).trim.replace(".", "").toString();
15
+ super(cleaned);
16
+ this.country = text(country).trim.upper.toString();
17
+ }
18
+ get isValid() {
19
+ if (!isNotEmpty(this.value))
20
+ return false;
21
+ return (0, import_validator.isVAT)(this.value, this.country);
22
+ }
23
+ };
24
+ var vat = (v, country) => new VAT(v, country);
25
+ export {
26
+ VAT,
27
+ vat
28
+ };
29
+ //# sourceMappingURL=VAT.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/values/VAT.ts"],"sourcesContent":["import { isNotEmpty, text, Value } from '@thisisagile/easy';\nimport { isVAT } from 'validator';\n\nexport class VAT extends Value {\n private readonly country: string;\n\n constructor(vat: unknown, country = 'NL') {\n const cleaned = text(vat).trim.replace('.', '').toString();\n super(cleaned);\n\n this.country = text(country).trim.upper.toString();\n }\n\n get isValid(): boolean {\n if (!isNotEmpty(this.value)) return false;\n return isVAT(this.value, this.country);\n }\n}\n\nexport const vat = (v: unknown, country?: string): VAT => new VAT(v, country);\n"],"mappings":";;;;;;;;AACA,uBAAsB;AADtB,SAAS,YAAY,MAAM,aAAa;AAGjC,IAAM,MAAN,cAAkB,MAAM;AAAA,EACZ;AAAA,EAEjB,YAAYA,MAAc,UAAU,MAAM;AACxC,UAAM,UAAU,KAAKA,IAAG,EAAE,KAAK,QAAQ,KAAK,EAAE,EAAE,SAAS;AACzD,UAAM,OAAO;AAEb,SAAK,UAAU,KAAK,OAAO,EAAE,KAAK,MAAM,SAAS;AAAA,EACnD;AAAA,EAEA,IAAI,UAAmB;AACrB,QAAI,CAAC,WAAW,KAAK,KAAK;AAAG,aAAO;AACpC,eAAO,wBAAM,KAAK,OAAO,KAAK,OAAO;AAAA,EACvC;AACF;AAEO,IAAM,MAAM,CAAC,GAAY,YAA0B,IAAI,IAAI,GAAG,OAAO;","names":["vat"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisisagile/easy-domain",
3
- "version": "17.20.7",
3
+ "version": "17.21.0",
4
4
  "description": "Common domain objects for easy microservices",
5
5
  "author": "Sander Hoogendoorn",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -18,3 +18,4 @@ export * from './values/DunsNumber';
18
18
  export * from './values/PostalCode';
19
19
  export * from './values/Slug';
20
20
  export * from './values/Url';
21
+ export * from './values/VAT';
@@ -0,0 +1,20 @@
1
+ import { isNotEmpty, text, Value } from '@thisisagile/easy';
2
+ import { isVAT } from 'validator';
3
+
4
+ export class VAT extends Value {
5
+ private readonly country: string;
6
+
7
+ constructor(vat: unknown, country = 'NL') {
8
+ const cleaned = text(vat).trim.replace('.', '').toString();
9
+ super(cleaned);
10
+
11
+ this.country = text(country).trim.upper.toString();
12
+ }
13
+
14
+ get isValid(): boolean {
15
+ if (!isNotEmpty(this.value)) return false;
16
+ return isVAT(this.value, this.country);
17
+ }
18
+ }
19
+
20
+ export const vat = (v: unknown, country?: string): VAT => new VAT(v, country);