@dzeio/schema 0.10.0 → 0.11.1
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/Schema.d.mts +1 -0
- package/dist/Schema.d.ts +1 -0
- package/dist/Schema.js +8 -2
- package/dist/Schema.mjs +8 -2
- package/package.json +1 -1
package/dist/Schema.d.mts
CHANGED
|
@@ -164,6 +164,7 @@ declare class SchemaAny extends SchemaItem {
|
|
|
164
164
|
type DateFormat = 'default' | 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy';
|
|
165
165
|
declare class SchemaDate extends SchemaItem<Date> {
|
|
166
166
|
static readonly id = "date";
|
|
167
|
+
constructor();
|
|
167
168
|
parseString(format?: DateFormat): this;
|
|
168
169
|
isOfType(input: unknown): input is Date;
|
|
169
170
|
}
|
package/dist/Schema.d.ts
CHANGED
|
@@ -164,6 +164,7 @@ declare class SchemaAny extends SchemaItem {
|
|
|
164
164
|
type DateFormat = 'default' | 'iso8601' | 'yy-mm-dd' | 'jj/mm/yy';
|
|
165
165
|
declare class SchemaDate extends SchemaItem<Date> {
|
|
166
166
|
static readonly id = "date";
|
|
167
|
+
constructor();
|
|
167
168
|
parseString(format?: DateFormat): this;
|
|
168
169
|
isOfType(input: unknown): input is Date;
|
|
169
170
|
}
|
package/dist/Schema.js
CHANGED
|
@@ -387,6 +387,12 @@ SchemaAny.id = "any";
|
|
|
387
387
|
|
|
388
388
|
// src/items/date.ts
|
|
389
389
|
var SchemaDate = class extends SchemaItem {
|
|
390
|
+
// overide the basic constructor to check that the date has a valid format
|
|
391
|
+
// purpose : reject incorrect date like '2020-30-45'
|
|
392
|
+
constructor() {
|
|
393
|
+
super();
|
|
394
|
+
this.addValidation((input) => !Number.isNaN(input.getDate()));
|
|
395
|
+
}
|
|
390
396
|
parseString(format = "default") {
|
|
391
397
|
this.addPreProcess((input) => {
|
|
392
398
|
if (typeof input !== "string") {
|
|
@@ -404,7 +410,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
404
410
|
if (splitted.length !== 3) {
|
|
405
411
|
break;
|
|
406
412
|
}
|
|
407
|
-
date = new Date(splitted[
|
|
413
|
+
date = /* @__PURE__ */ new Date(`${splitted[0]}-${splitted[1]}-${splitted[2]}`);
|
|
408
414
|
break;
|
|
409
415
|
}
|
|
410
416
|
case "jj/mm/yy": {
|
|
@@ -412,7 +418,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
412
418
|
if (splitted.length !== 3) {
|
|
413
419
|
break;
|
|
414
420
|
}
|
|
415
|
-
date = new Date(splitted[2]
|
|
421
|
+
date = /* @__PURE__ */ new Date(`${splitted[2]}-${splitted[1]}-${splitted[0]}`);
|
|
416
422
|
break;
|
|
417
423
|
}
|
|
418
424
|
}
|
package/dist/Schema.mjs
CHANGED
|
@@ -335,6 +335,12 @@ SchemaAny.id = "any";
|
|
|
335
335
|
|
|
336
336
|
// src/items/date.ts
|
|
337
337
|
var SchemaDate = class extends SchemaItem {
|
|
338
|
+
// overide the basic constructor to check that the date has a valid format
|
|
339
|
+
// purpose : reject incorrect date like '2020-30-45'
|
|
340
|
+
constructor() {
|
|
341
|
+
super();
|
|
342
|
+
this.addValidation((input) => !Number.isNaN(input.getDate()));
|
|
343
|
+
}
|
|
338
344
|
parseString(format = "default") {
|
|
339
345
|
this.addPreProcess((input) => {
|
|
340
346
|
if (typeof input !== "string") {
|
|
@@ -352,7 +358,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
352
358
|
if (splitted.length !== 3) {
|
|
353
359
|
break;
|
|
354
360
|
}
|
|
355
|
-
date = new Date(splitted[
|
|
361
|
+
date = /* @__PURE__ */ new Date(`${splitted[0]}-${splitted[1]}-${splitted[2]}`);
|
|
356
362
|
break;
|
|
357
363
|
}
|
|
358
364
|
case "jj/mm/yy": {
|
|
@@ -360,7 +366,7 @@ var SchemaDate = class extends SchemaItem {
|
|
|
360
366
|
if (splitted.length !== 3) {
|
|
361
367
|
break;
|
|
362
368
|
}
|
|
363
|
-
date = new Date(splitted[2]
|
|
369
|
+
date = /* @__PURE__ */ new Date(`${splitted[2]}-${splitted[1]}-${splitted[0]}`);
|
|
364
370
|
break;
|
|
365
371
|
}
|
|
366
372
|
}
|