structure-verifier 0.0.16 → 1.0.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.
Files changed (35) hide show
  1. package/README.md +318 -241
  2. package/dist/index.d.ts +8 -16
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/error/v_error.js +4 -3
  5. package/dist/src/error/v_error.js.map +1 -1
  6. package/dist/src/verifiers/any/v_any.js +0 -1
  7. package/dist/src/verifiers/any/v_any.js.map +1 -1
  8. package/dist/src/verifiers/array/v_array.d.ts +21 -3
  9. package/dist/src/verifiers/array/v_array.js +24 -5
  10. package/dist/src/verifiers/array/v_array.js.map +1 -1
  11. package/dist/src/verifiers/boolean/v_boolean.d.ts +4 -0
  12. package/dist/src/verifiers/boolean/v_boolean.js +15 -5
  13. package/dist/src/verifiers/boolean/v_boolean.js.map +1 -1
  14. package/dist/src/verifiers/date/v_date.d.ts +26 -0
  15. package/dist/src/verifiers/date/v_date.js +28 -1
  16. package/dist/src/verifiers/date/v_date.js.map +1 -1
  17. package/dist/src/verifiers/helpers/conditionMessage.d.ts +3 -0
  18. package/dist/src/verifiers/helpers/conditionMessage.js +19 -0
  19. package/dist/src/verifiers/helpers/conditionMessage.js.map +1 -0
  20. package/dist/src/verifiers/number/v_number.d.ts +38 -0
  21. package/dist/src/verifiers/number/v_number.js +40 -1
  22. package/dist/src/verifiers/number/v_number.js.map +1 -1
  23. package/dist/src/verifiers/object/v_object.d.ts +7 -0
  24. package/dist/src/verifiers/object/v_object.js +21 -0
  25. package/dist/src/verifiers/object/v_object.js.map +1 -1
  26. package/dist/src/verifiers/string/v_string.d.ts +58 -0
  27. package/dist/src/verifiers/string/v_string.js +109 -11
  28. package/dist/src/verifiers/string/v_string.js.map +1 -1
  29. package/dist/src/verifiers/uuid/v_uuid.d.ts +8 -0
  30. package/dist/src/verifiers/uuid/v_uuid.js +35 -4
  31. package/dist/src/verifiers/uuid/v_uuid.js.map +1 -1
  32. package/dist/src/verifiers/verifier.d.ts +1 -0
  33. package/dist/src/verifiers/verifier.js +8 -0
  34. package/dist/src/verifiers/verifier.js.map +1 -1
  35. package/package.json +1 -1
package/README.md CHANGED
@@ -1,8 +1,34 @@
1
- # structure-verifier 0.0.16
1
+ # structure-verifier
2
2
 
3
- Libreria TypeScript para validar estructuras de datos con tipado inferido.
3
+ Libreria de validacion para TypeScript orientada a esquemas declarativos, tipado inferido y errores detallados por ruta.
4
4
 
5
- Permite validar valores simples y estructuras anidadas (objetos y arrays), con errores detallados por ruta (por ejemplo: name, items[0], address.city).
5
+ Ideal para validar payloads de API, formularios, configuraciones y estructuras anidadas.
6
+
7
+ ## Objetivo de esta documentacion
8
+
9
+ Este README está diseñado para ayudarte a:
10
+
11
+ - Comprender rápidamente cómo funciona la librería.
12
+ - Integrarla de forma sencilla en un proyecto real.
13
+ - Conocer el contrato público de la API antes de utilizarla en producción.
14
+ - Explorar ejemplos prácticos de validación y tipado.
15
+ - Entender las decisiones de diseño y el enfoque de la librería.
16
+
17
+ ## Tabla de contenido
18
+
19
+ - [Instalacion](#instalacion)
20
+ - [Inicio rapido](#inicio-rapido)
21
+ - [Conceptos clave](#conceptos-clave)
22
+ - [API publica](#api-publica)
23
+ - [Estilos de uso](#estilos-de-uso)
24
+ - [Validadores disponibles](#validadores-disponibles)
25
+ - [Transformaciones](#transformaciones)
26
+ - [Tipado inferido](#tipado-inferido)
27
+ - [Manejo de errores](#manejo-de-errores)
28
+ - [datetime (dayjs)](#datetime-dayjs)
29
+ - [Buenas practicas para v1.0.0](#buenas-practicas-para-v100)
30
+ - [Scripts de desarrollo](#scripts-de-desarrollo)
31
+ - [Licencia](#licencia)
6
32
 
7
33
  ## Instalacion
8
34
 
@@ -15,34 +41,94 @@ npm install structure-verifier
15
41
  ```ts
16
42
  import { Verifiers as V, VerificationError } from "structure-verifier";
17
43
 
18
- const userValidator = V.ObjectNotNull({
19
- id: V.UUIDNotNull({ version: 4 }),
20
- name: V.StringNotNull({ minLength: 2 }),
21
- age: V.Number({ min: 0 }),
22
- active: V.BooleanNotNull(),
23
- });
44
+ const userVerifier = V.ObjectNotNull(
45
+ {
46
+ id: V.UUID({ version: 4 }).required(),
47
+ name: V.StringNotNull({ minLength: 2 }).trim(),
48
+ age: V.Number({ min: 0 }),
49
+ active: V.BooleanNotNull(),
50
+ tags: V.ArrayNotNull(V.StringNotNull(), { minLength: 1 }),
51
+ },
52
+ {
53
+ strictMode: true,
54
+ },
55
+ );
24
56
 
25
57
  try {
26
- const user = userValidator.check({
58
+ const user = userVerifier.check({
27
59
  id: "550e8400-e29b-41d4-a716-446655440000",
28
- name: "Ana",
29
- age: 31,
60
+ name: " Ana ",
61
+ age: "31",
30
62
  active: "true",
63
+ tags: ["admin"],
31
64
  });
32
65
 
33
- // user queda tipado con los tipos inferidos de cada propiedad
34
66
  console.log(user);
67
+ // {
68
+ // id: "550e8400-e29b-41d4-a716-446655440000",
69
+ // name: "Ana",
70
+ // age: 31,
71
+ // active: true,
72
+ // tags: ["admin"]
73
+ // }
35
74
  } catch (error) {
36
75
  if (error instanceof VerificationError) {
37
- console.log(error.errors); // mensajes planos
38
- console.log(error.errorsObj); // mensajes con key y metadatos
76
+ console.error(error.message);
77
+ console.error(error.errors);
78
+ console.error(error.errorsObj);
39
79
  }
40
80
  }
41
81
  ```
42
82
 
83
+ ## Conceptos clave
84
+
85
+ ### 1) Nullable vs NotNull
86
+
87
+ - `VNumber`, `VString`, `VBoolean`, `VDate`, `VUUID`, `VArray`, `VObject` y `VAny` pueden devolver `null`.
88
+ - Las variantes `NotNull` devuelven siempre tipo requerido.
89
+ - En validadores nullable puedes promover a requerido con `.required()`.
90
+
91
+ ### 2) Inmutabilidad de reglas
92
+
93
+ Cada metodo de regla devuelve una nueva instancia del validador.
94
+
95
+ ```ts
96
+ const base = V.StringNotNull();
97
+ const withMin = base.minLength(3);
98
+
99
+ // base no cambia
100
+ ```
101
+
102
+ ### 3) Reglas transversales
103
+
104
+ Muchos validadores comparten estas opciones:
105
+
106
+ - `isRequired`: fuerza existencia del valor.
107
+ - `emptyAsNull`: transforma `""` a `null` antes de validar.
108
+ - `defaultValue`: valor por defecto para `undefined` y ciertos casos de `null`.
109
+ - `badTypeMessage`: reemplaza mensaje de tipo invalido.
110
+
111
+ ### 4) Mensajes personalizados
112
+
113
+ Puedes pasar mensajes como:
114
+
115
+ - `string` fijo.
116
+ - callback usando el valor de la regla.
117
+ - objeto `{ val, message }`.
118
+
119
+ ```ts
120
+ const age = V.NumberNotNull().min(18, (v) => `Edad minima: ${v.min}`);
121
+ ```
122
+
43
123
  ## API publica
44
124
 
45
- Import principal:
125
+ Import principal recomendado:
126
+
127
+ ```ts
128
+ import { Verifiers as V } from "structure-verifier";
129
+ ```
130
+
131
+ Import completo disponible:
46
132
 
47
133
  ```ts
48
134
  import {
@@ -52,345 +138,336 @@ import {
52
138
  InferType,
53
139
  InferFactoryType,
54
140
  VAny,
55
- VAnyConditions,
56
141
  VArray,
57
142
  VArrayNotNull,
58
- VArrayConditions,
59
143
  VBoolean,
60
144
  VBooleanNotNull,
61
- VBooleanConditions,
62
145
  VDate,
63
146
  VDateNotNull,
64
- VDateConditions,
65
147
  VNumber,
66
148
  VNumberNotNull,
67
- VNumberConditions,
68
149
  VObject,
69
150
  VObjectNotNull,
70
- VObjectConditions,
71
- VObjectConditionsNotNull,
72
151
  VString,
73
152
  VStringNotNull,
74
- VStringConditions,
75
153
  VUUID,
76
154
  VUUIDNotNull,
77
- VUUIDConditions,
78
155
  datetime,
79
156
  } from "structure-verifier";
80
157
  ```
81
158
 
82
- ## Formas de uso
159
+ Tambien se exportan estos tipos de condiciones:
83
160
 
84
- La libreria soporta dos estilos:
161
+ - `VAnyConditions`
162
+ - `VArrayConditions`
163
+ - `VBooleanConditions`
164
+ - `VDateConditions`
165
+ - `VNumberConditions`
166
+ - `VObjectConditions`
167
+ - `VObjectConditionsNotNull`
168
+ - `VStringConditions`
169
+ - `VUUIDConditions`
85
170
 
86
- 1. API recomendada con Verifiers (callable, con o sin new)
87
- 2. Clases directas (new VString(...), new VObject(...), etc.)
171
+ ## Estilos de uso
88
172
 
89
- Ejemplo con Verifiers:
173
+ ### API de fabrica (recomendada)
90
174
 
91
175
  ```ts
92
176
  import { Verifiers as V } from "structure-verifier";
93
177
 
94
- const a = V.StringNotNull({ minLength: 3 });
95
- const b = new V.StringNotNull({ minLength: 3 });
178
+ const nameV = V.StringNotNull({ minLength: 3 });
179
+ ```
96
180
 
97
- console.log(a.check("hola"));
98
- console.log(b.check("hola"));
181
+ ### Clases directas
182
+
183
+ ```ts
184
+ import { VStringNotNull } from "structure-verifier";
185
+
186
+ const nameV = new VStringNotNull({ minLength: 3 });
99
187
  ```
100
188
 
101
- ## Inferencia de tipos
189
+ ### Callable constructors en `Verifiers`
102
190
 
103
- ### InferType
191
+ Los miembros de `Verifiers` aceptan llamada normal o `new`.
104
192
 
105
193
  ```ts
106
- import { InferType, Verifiers as V } from "structure-verifier";
194
+ const a = V.NumberNotNull({ min: 1 });
195
+ const b = new V.NumberNotNull({ min: 1 });
196
+ ```
107
197
 
108
- const v = V.ObjectNotNull({
109
- id: V.UUIDNotNull(),
110
- tags: V.ArrayNotNull(V.StringNotNull()),
111
- });
198
+ ## Validadores disponibles
112
199
 
113
- type User = InferType<typeof v>;
114
- ```
200
+ ### Number / NumberNotNull
115
201
 
116
- ### InferFactoryType
202
+ Salida:
117
203
 
118
- Funciona con funciones que retornan un Verifier (por ejemplo, miembros callable de Verifiers).
204
+ - `VNumber`: `number | null`
205
+ - `VNumberNotNull`: `number`
119
206
 
120
- ```ts
121
- import { InferFactoryType, Verifiers as V } from "structure-verifier";
207
+ Reglas:
122
208
 
123
- type NullableNumber = InferFactoryType<typeof V.Number>; // number | null
124
- type RequiredNumber = InferFactoryType<typeof V.NumberNotNull>; // number
125
- ```
209
+ - `min`
210
+ - `max`
211
+ - `in`
212
+ - `notIn`
213
+ - `maxDecimalPlaces`
214
+ - `minDecimalPlaces`
215
+ - reglas transversales (`isRequired`, `emptyAsNull`, `defaultValue`, `badTypeMessage`)
126
216
 
127
- ## Manejo de errores
217
+ Comportamiento importante:
128
218
 
129
- Cuando una validacion falla se lanza VerificationError.
219
+ - Convierte con `Number(data)`.
220
+ - Rechaza `""` y valores `NaN`.
130
221
 
131
- ```ts
132
- try {
133
- V.NumberNotNull({ min: 10 }).check(5);
134
- } catch (error) {
135
- if (error instanceof VerificationError) {
136
- console.log(error.errors); // ["debe ser mayor o igual a 10"]
137
- console.log(error.errorsObj); // [{ key: "", message: "..." }]
138
- }
139
- }
140
- ```
222
+ ### String / StringNotNull
141
223
 
142
- ## Opciones comunes
224
+ Salida:
143
225
 
144
- Muchos validadores comparten estas opciones:
226
+ - `VString`: `string | null`
227
+ - `VStringNotNull`: `string`
145
228
 
146
- - isRequired: fuerza que el valor exista.
147
- - emptyAsNull: si llega string vacio, se convierte a null antes de validar.
148
- - defaultValue: valor por defecto si llega undefined (y en algunos flujos tambien null).
149
- - badTypeMessage: mensaje personalizado de tipo invalido.
229
+ Reglas:
150
230
 
151
- Puedes pasar mensajes simples o mensajes dinamicos con estructura:
231
+ - `minLength`
232
+ - `maxLength`
233
+ - `regex`
234
+ - `notRegex`
235
+ - `in`
236
+ - `notIn`
237
+ - `strictMode`
238
+ - `ignoreCase`
239
+ - reglas transversales
152
240
 
153
- ```ts
154
- { val: valorReal, message: (values) => "mensaje" }
155
- ```
241
+ Comportamiento importante:
156
242
 
157
- ## Validadores
243
+ - En modo normal convierte con `String(data)`.
244
+ - En `strictMode` exige tipo string real.
245
+ - `ignoreCase` aplica a reglas `in` y `notIn`.
158
246
 
159
- ### Number / NumberNotNull
247
+ ### Boolean / BooleanNotNull
160
248
 
161
- ```ts
162
- const n1 = V.Number();
163
- const n2 = V.NumberNotNull();
164
- ```
249
+ Salida:
165
250
 
166
- Condiciones:
251
+ - `VBoolean`: `boolean | null`
252
+ - `VBooleanNotNull`: `boolean`
167
253
 
168
- - min
169
- - max
170
- - in
171
- - notIn
172
- - maxDecimalPlaces
173
- - minDecimalPlaces
174
- - isRequired
175
- - emptyAsNull
176
- - defaultValue
177
- - badTypeMessage
254
+ Reglas:
178
255
 
179
- Notas:
256
+ - `strictMode`
257
+ - reglas transversales
180
258
 
181
- - Convierte con Number(data), por lo que acepta strings numericos como "42".
182
- - "" y NaN fallan.
259
+ Comportamiento importante:
183
260
 
184
- ### String / StringNotNull
261
+ - Modo normal acepta: `true`, `false`, `1`, `0`, `"1"`, `"0"`, `"true"`, `"false"`.
262
+ - `strictMode` acepta solo boolean real.
185
263
 
186
- ```ts
187
- const s1 = V.String();
188
- const s2 = V.StringNotNull();
189
- ```
264
+ ### UUID / UUIDNotNull
190
265
 
191
- Condiciones:
266
+ Salida:
192
267
 
193
- - minLength
194
- - maxLength
195
- - regex
196
- - notRegex
197
- - in
198
- - notIn
199
- - strictMode
200
- - ignoreCase
201
- - isRequired
202
- - emptyAsNull
203
- - defaultValue
204
- - badTypeMessage
268
+ - `VUUID`: `string | null`
269
+ - `VUUIDNotNull`: `string`
205
270
 
206
- Notas:
271
+ Reglas:
207
272
 
208
- - En modo no estricto convierte con String(data).
209
- - En strictMode exige typeof data === "string".
210
- - ignoreCase afecta in y notIn.
273
+ - `version` (`1 | 2 | 3 | 4 | 5`)
274
+ - `allowNoHyphens`
275
+ - `strictMode`
276
+ - reglas transversales
211
277
 
212
- ### Boolean / BooleanNotNull
278
+ Comportamiento importante:
213
279
 
214
- ```ts
215
- const b1 = V.Boolean();
216
- const b2 = V.BooleanNotNull();
217
- ```
280
+ - Normaliza salida a minusculas con formato `8-4-4-4-12`.
281
+ - Si `allowNoHyphens` es `false`, exige UUID con guiones.
218
282
 
219
- Condiciones:
283
+ ### Date / DateNotNull
220
284
 
221
- - strictMode
222
- - isRequired
223
- - emptyAsNull
224
- - defaultValue
225
- - badTypeMessage
285
+ Salida:
226
286
 
227
- Notas:
287
+ - `VDate`: `datetime.Dayjs | null`
288
+ - `VDateNotNull`: `datetime.Dayjs`
228
289
 
229
- - En modo no estricto acepta: true, false, 1, 0, "1", "0", "true", "false" (case-insensitive).
230
- - En strictMode solo acepta boolean real.
290
+ Reglas:
231
291
 
232
- ### UUID / UUIDNotNull
292
+ - `format`
293
+ - `timeZone`
294
+ - `maxDate`
295
+ - `minDate`
296
+ - reglas transversales
233
297
 
234
- ```ts
235
- const u1 = V.UUID();
236
- const u2 = V.UUIDNotNull();
237
- ```
298
+ Comportamiento importante:
238
299
 
239
- Condiciones:
300
+ - Soporta entrada `number`, `string`, `Date` y `datetime.Dayjs`.
301
+ - Si no defines `timeZone`, usa `UTC`.
302
+ - Si el `format` no incluye zona horaria, aplica la zona configurada.
240
303
 
241
- - version (1 | 2 | 3 | 4 | 5)
242
- - allowNoHyphens
243
- - strictMode
244
- - isRequired
245
- - emptyAsNull
246
- - defaultValue
247
- - badTypeMessage
304
+ ### Array / ArrayNotNull
248
305
 
249
- Notas:
306
+ Salida:
250
307
 
251
- - Devuelve UUID normalizado en minusculas y con guiones.
252
- - Si allowNoHyphens es false, exige formato 8-4-4-4-12.
308
+ - `VArray`: `ReturnType<T["check"]>[] | null`
309
+ - `VArrayNotNull`: `ReturnType<T["check"]>[]`
253
310
 
254
- ### Date / DateNotNull
311
+ Reglas:
255
312
 
256
- ```ts
257
- import { Verifiers as V, datetime } from "structure-verifier";
258
-
259
- const d1 = V.Date();
260
- const d2 = V.DateNotNull({
261
- format: "YYYY-MM-DD",
262
- timeZone: "UTC",
263
- minDate: datetime("2024-01-01"),
264
- maxDate: datetime("2026-12-31"),
265
- });
266
- ```
313
+ - `minLength`
314
+ - `maxLength`
315
+ - reglas transversales
316
+
317
+ Comportamiento importante:
318
+
319
+ - Valida item por item con el verificador interno.
320
+ - En errores anidados agrega rutas como `[0]`, `[1].name`, etc.
321
+
322
+ ### Object / ObjectNotNull
323
+
324
+ Salida:
325
+
326
+ - `VObject`: objeto tipado o `null`
327
+ - `VObjectNotNull`: objeto tipado
267
328
 
268
- Condiciones:
329
+ Reglas:
269
330
 
270
- - format
271
- - timeZone
272
- - minDate
273
- - maxDate
274
- - default
275
- - isRequired
276
- - emptyAsNull
277
- - defaultValue
278
- - badTypeMessage
331
+ - `invalidPropertyMessage`
332
+ - `strictMode`
333
+ - `ignoreCase`
334
+ - `takeAllValues`
335
+ - `conds`
336
+ - reglas transversales
279
337
 
280
- Notas:
338
+ Comportamiento importante:
281
339
 
282
- - Retorna instancias dayjs (re-exportado como datetime).
283
- - Inputs soportados: number, string, Date y datetime.Dayjs.
284
- - timeZone por defecto: UTC.
340
+ - `strictMode`: rechaza propiedades no declaradas.
341
+ - `ignoreCase`: permite mapear llaves sin distinguir mayusculas/minusculas.
342
+ - `takeAllValues`: conserva propiedades extra en la salida.
343
+ - `conds`: ejecuta validacion de negocio final sobre el objeto ya validado.
285
344
 
286
345
  ### Any
287
346
 
288
- ```ts
289
- const anyVal = V.Any();
290
- ```
347
+ Salida:
291
348
 
292
- Condiciones:
349
+ - `VAny`: `any | null`
293
350
 
294
- - isRequired
295
- - emptyAsNull
296
- - defaultValue
297
- - badTypeMessage
351
+ Reglas:
298
352
 
299
- ### Array / ArrayNotNull
353
+ - reglas transversales
354
+
355
+ ## Transformaciones
300
356
 
301
- Firma:
357
+ La clase base `Verifier` incluye `transform(mapper)` para postprocesar salida validada.
358
+
359
+ `VString` y `VStringNotNull` incluyen helpers:
360
+
361
+ - `trim`
362
+ - `trimStart`
363
+ - `trimEnd`
364
+ - `toLowerCase`
365
+ - `toUpperCase`
366
+ - `removeAccents`
367
+ - `padStart`
368
+ - `padEnd`
302
369
 
303
370
  ```ts
304
- const arr1 = V.Array(verifier, conditions?);
305
- const arr2 = V.ArrayNotNull(verifier, conditions?);
371
+ const usernameV = V.StringNotNull({ minLength: 3 })
372
+ .trim()
373
+ .toLowerCase()
374
+ .removeAccents();
306
375
  ```
307
376
 
308
- Ejemplo:
377
+ ## Tipado inferido
378
+
379
+ ### InferType
309
380
 
310
381
  ```ts
311
- const numbers = V.ArrayNotNull(V.NumberNotNull(), {
312
- minLength: 1,
313
- maxLength: 5,
382
+ import { InferType, Verifiers as V } from "structure-verifier";
383
+
384
+ const schema = V.ObjectNotNull({
385
+ id: V.UUIDNotNull(),
386
+ profile: V.ObjectNotNull({
387
+ name: V.StringNotNull(),
388
+ age: V.Number(),
389
+ }),
314
390
  });
391
+
392
+ type User = InferType<typeof schema>;
315
393
  ```
316
394
 
317
- Condiciones:
395
+ ### InferFactoryType
318
396
 
319
- - minLength
320
- - maxLength
321
- - isRequired
322
- - emptyAsNull
323
- - defaultValue
324
- - badTypeMessage
397
+ ```ts
398
+ import { InferFactoryType, Verifiers as V } from "structure-verifier";
325
399
 
326
- Notas:
400
+ type NumberMaybe = InferFactoryType<typeof V.Number>;
401
+ type NumberRequired = InferFactoryType<typeof V.NumberNotNull>;
402
+ ```
327
403
 
328
- - Valida item por item con el verificador interno.
329
- - En errores anidados utiliza claves como [0], [1].name, etc.
404
+ ## Manejo de errores
330
405
 
331
- ### Object / ObjectNotNull
406
+ Cuando una validacion falla se lanza `VerificationError`.
332
407
 
333
- Firma:
408
+ Campos principales:
334
409
 
335
- ```ts
336
- const o1 = V.Object(properties, conditions?);
337
- const o2 = V.ObjectNotNull(properties, conditions?);
338
- ```
410
+ - `message`: string unico con errores concatenados por `;`.
411
+ - `errors`: arreglo de mensajes planos.
412
+ - `errorsObj`: arreglo con `key`, `message` y metadatos.
339
413
 
340
414
  Ejemplo:
341
415
 
342
416
  ```ts
343
- const user = V.ObjectNotNull(
344
- {
345
- name: V.StringNotNull({ minLength: 3 }),
346
- age: V.NumberNotNull({ min: 18 }),
347
- },
348
- {
349
- strictMode: true,
350
- ignoreCase: true,
351
- takeAllValues: false,
352
- },
353
- );
354
- ```
355
-
356
- Condiciones:
417
+ import { Verifiers as V, VerificationError } from "structure-verifier";
357
418
 
358
- - invalidPropertyMessage
359
- - strictMode
360
- - ignoreCase
361
- - takeAllValues
362
- - conds
363
- - isRequired
364
- - emptyAsNull
365
- - defaultValue
366
- - badTypeMessage
419
+ try {
420
+ V.ObjectNotNull(
421
+ {
422
+ name: V.StringNotNull({ minLength: 3 }),
423
+ tags: V.ArrayNotNull(V.StringNotNull(), { minLength: 1 }),
424
+ },
425
+ { strictMode: true },
426
+ ).check({ name: "Al", tags: [], extra: true });
427
+ } catch (error) {
428
+ if (error instanceof VerificationError) {
429
+ console.log(error.message);
430
+ console.log(error.errors);
431
+ console.log(error.errorsObj);
432
+ }
433
+ }
434
+ ```
367
435
 
368
- Notas:
436
+ Posible salida en `errorsObj`:
369
437
 
370
- - strictMode rechaza propiedades extra.
371
- - ignoreCase permite mapear propiedades sin importar mayusculas/minusculas.
372
- - takeAllValues conserva propiedades no definidas en el esquema.
373
- - conds ejecuta una validacion adicional al final con el objeto ya tipado.
438
+ ```ts
439
+ [
440
+ { key: "name", message: "debe tener una longitud minima de 3" },
441
+ { key: "tags", message: "debe tener al menos 1 elementos" },
442
+ { key: "extra", message: "no es una propiedad valida" },
443
+ ];
444
+ ```
374
445
 
375
446
  ## datetime (dayjs)
376
447
 
377
- La libreria re-exporta dayjs como datetime con plugins:
448
+ La libreria exporta `dayjs` como `datetime` con plugins habilitados:
378
449
 
379
- - utc
380
- - timezone
381
- - customParseFormat
382
-
383
- Ejemplo:
450
+ - `utc`
451
+ - `timezone`
452
+ - `customParseFormat`
384
453
 
385
454
  ```ts
386
455
  import { datetime } from "structure-verifier";
387
456
 
388
457
  const now = datetime();
389
- console.log(now.tz("UTC").format());
458
+ const utc = now.tz("UTC").format();
459
+ console.log(utc);
390
460
  ```
391
461
 
392
- ## Ejecutar tests del proyecto
462
+ ## Buenas practicas para v1.0.0
393
463
 
394
- ```bash
395
- npm test
396
- ```
464
+ - Define siempre `strictMode: true` en payloads de entrada externa.
465
+ - Usa variantes `NotNull` en campos de negocio obligatorios.
466
+ - Agrega reglas semanticas con `conds` para validaciones cruzadas.
467
+ - Encadena normalizaciones (`trim`, `toLowerCase`, etc.) para salida consistente.
468
+ - Centraliza mensajes custom cuando quieras UX de errores uniforme.
469
+ - Cubre cada esquema critico con pruebas de casos validos e invalidos.
470
+
471
+ ## Licencia
472
+
473
+ ISC