@win2win/shared 1.0.105 → 1.0.107

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.
@@ -10,7 +10,9 @@ export declare enum PropValidatorKeys {
10
10
  MAXIMO = "max",
11
11
  SOLO_NUMEROS = "onlyNumbers",
12
12
  EMAIL = "email",
13
- URL = "url"
13
+ URL = "url",
14
+ DNI = "dni",
15
+ IBAN = "iban"
14
16
  }
15
17
  export declare const VALIDATORS: {
16
18
  fn: (val: number) => (control: GamaPropModel) => boolean;
@@ -1,23 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VALIDATORS = exports.PropValidatorKeys = exports.GamaPropValidatorsMap = void 0;
4
+ const better_dni_1 = require("better-dni");
5
+ const iban = require("iban");
4
6
  exports.GamaPropValidatorsMap = {
5
7
  required: {
6
8
  fn: () => (control) => {
7
- return control.value !== null && control.value !== undefined && control.value !== '';
9
+ return (control.value !== null &&
10
+ control.value !== undefined &&
11
+ control.value !== "");
8
12
  },
9
- message: 'Este campo es requerido',
10
- label: 'Requerido',
13
+ message: "Este campo es requerido",
14
+ label: "Requerido",
11
15
  },
12
16
  min: {
13
17
  fn: (min) => (control) => {
14
- if (typeof control.value === 'number') {
18
+ if (typeof control.value === "number") {
15
19
  return (control.value || 0) >= min;
16
20
  }
17
- if (typeof control.value === 'string') {
18
- const value = control.value || '';
21
+ if (typeof control.value === "string") {
22
+ const value = control.value || "";
19
23
  if (control.multiple) {
20
- const array = value.split(',');
24
+ const array = value.split(",");
21
25
  return array.length >= min;
22
26
  }
23
27
  else {
@@ -26,56 +30,73 @@ exports.GamaPropValidatorsMap = {
26
30
  }
27
31
  return false;
28
32
  },
29
- message: 'El valor es menor al mínimo permitido',
30
- label: 'Mínimo',
33
+ message: "El valor es menor al mínimo permitido",
34
+ label: "Mínimo",
31
35
  },
32
36
  max: {
33
37
  fn: (max) => (control) => {
34
- if (typeof control.value === 'number') {
38
+ if (typeof control.value === "number") {
35
39
  return (control.value || 0) <= max;
36
40
  }
37
- if (typeof control.value === 'string') {
38
- const value = control.value || '';
41
+ if (typeof control.value === "string") {
42
+ const value = control.value || "";
39
43
  if (control.multiple) {
40
- const array = value.split(',');
44
+ const array = value.split(",");
41
45
  return array.length <= max;
42
46
  }
43
47
  else {
44
- return (value || '').length <= max;
48
+ return (value || "").length <= max;
45
49
  }
46
50
  }
47
51
  return false;
48
52
  },
49
- message: 'El valor es mayor al máximo permitido',
50
- label: 'Máximo',
53
+ message: "El valor es mayor al máximo permitido",
54
+ label: "Máximo",
51
55
  },
52
56
  onlyNumbers: {
53
57
  fn: () => (control) => {
54
- return /^[0-9]*$/.test(String(control.value) || '');
58
+ return /^[0-9]*$/.test(String(control.value) || "");
55
59
  },
56
- message: 'Este campo solo acepta números',
57
- label: 'Solo números',
60
+ message: "Este campo solo acepta números",
61
+ label: "Solo números",
58
62
  },
59
63
  email: {
60
64
  fn: () => (control) => {
61
65
  if (!control.value)
62
66
  return true;
63
- return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(control.value) || '');
67
+ return /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(String(control.value) || "");
64
68
  },
65
- message: 'El correo electrónico no es válido',
66
- label: 'Correo electrónico',
69
+ message: "El correo electrónico no es válido",
70
+ label: "Correo electrónico",
67
71
  },
68
72
  url: {
69
73
  fn: () => (control) => {
70
74
  if (!control.value)
71
75
  return true;
72
- return /^(ftp|http|https):\/\/[^ "]+$/.test(String(control.value) || '') || /^www\.[^ "]+$/.test(String(control.value) || '');
76
+ return (/^(ftp|http|https):\/\/[^ "]+$/.test(String(control.value) || "") ||
77
+ /^www\.[^ "]+$/.test(String(control.value) || ""));
73
78
  },
74
- message: 'La URL no es válida',
75
- label: 'URL',
79
+ message: "La URL no es válida",
80
+ label: "URL",
81
+ },
82
+ dni: {
83
+ fn: () => (control) => {
84
+ if (!control.value)
85
+ return true;
86
+ return (0, better_dni_1.isValid)(String(control.value) || "");
87
+ },
88
+ message: "El dni no es válido",
89
+ label: "Identificación (DNI, NIF, NIE)",
90
+ },
91
+ iban: {
92
+ fn: () => (control) => {
93
+ if (!control.value)
94
+ return true;
95
+ return iban.isValid(String(control.value) || "");
96
+ },
97
+ message: "El IBAN no es válido",
98
+ label: "Cuenta Bancaria (IBAN)",
76
99
  },
77
- // minLength: (length: number) => (control: FormControlModel) => {},
78
- // maxLength: (length: number) => (control: FormControlModel) => {},
79
100
  };
80
101
  var PropValidatorKeys;
81
102
  (function (PropValidatorKeys) {
@@ -85,5 +106,7 @@ var PropValidatorKeys;
85
106
  PropValidatorKeys["SOLO_NUMEROS"] = "onlyNumbers";
86
107
  PropValidatorKeys["EMAIL"] = "email";
87
108
  PropValidatorKeys["URL"] = "url";
109
+ PropValidatorKeys["DNI"] = "dni";
110
+ PropValidatorKeys["IBAN"] = "iban";
88
111
  })(PropValidatorKeys || (exports.PropValidatorKeys = PropValidatorKeys = {}));
89
112
  exports.VALIDATORS = Object.entries(exports.GamaPropValidatorsMap).map(([key, value]) => ({ value: key, ...value }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@win2win/shared",
3
- "version": "1.0.105",
3
+ "version": "1.0.107",
4
4
  "description": "Tipos, interfaces, funciones, constantes, clases y enums compartidos por todos los proyectos de Win2Win",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,11 @@
15
15
  "dist/**/*"
16
16
  ],
17
17
  "devDependencies": {
18
+ "@types/iban": "^0.0.35",
19
+ "iban": "^0.0.14",
18
20
  "typescript": "^5.5.2"
21
+ },
22
+ "dependencies": {
23
+ "better-dni": "^4.4.2"
19
24
  }
20
25
  }
21
-