@naturalcycles/nodejs-lib 12.73.0 → 12.74.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.
|
@@ -38,6 +38,8 @@ function getAjv(opt) {
|
|
|
38
38
|
return ajv;
|
|
39
39
|
}
|
|
40
40
|
exports.getAjv = getAjv;
|
|
41
|
+
const TS_2500 = 16725225600; // 2500-01-01
|
|
42
|
+
const TS_2000 = 946684800; // 2000-01-01
|
|
41
43
|
function addCustomAjvFormats(ajv) {
|
|
42
44
|
return (ajv
|
|
43
45
|
.addFormat('id', /^[a-z0-9_]{6,64}$/)
|
|
@@ -50,15 +52,25 @@ function addCustomAjvFormats(ajv) {
|
|
|
50
52
|
.addFormat('unixTimestamp', {
|
|
51
53
|
type: 'number',
|
|
52
54
|
validate: (n) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
return n >= 0 && n < TS_2500;
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
.addFormat('unixTimestamp2000', {
|
|
59
|
+
type: 'number',
|
|
60
|
+
validate: (n) => {
|
|
61
|
+
return n >= TS_2000 && n < TS_2500;
|
|
55
62
|
},
|
|
56
63
|
})
|
|
57
64
|
.addFormat('unixTimestampMillis', {
|
|
58
65
|
type: 'number',
|
|
59
66
|
validate: (n) => {
|
|
60
|
-
|
|
61
|
-
|
|
67
|
+
return n >= 0 && n < TS_2500 * 1000;
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
.addFormat('unixTimestampMillis2000', {
|
|
71
|
+
type: 'number',
|
|
72
|
+
validate: (n) => {
|
|
73
|
+
return n >= TS_2000 * 1000 && n < TS_2500 * 1000;
|
|
62
74
|
},
|
|
63
75
|
})
|
|
64
76
|
.addFormat('utcOffset', {
|
package/package.json
CHANGED
|
@@ -43,6 +43,9 @@ export function getAjv(opt?: Options): Ajv {
|
|
|
43
43
|
return ajv
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
const TS_2500 = 16725225600 // 2500-01-01
|
|
47
|
+
const TS_2000 = 946684800 // 2000-01-01
|
|
48
|
+
|
|
46
49
|
function addCustomAjvFormats(ajv: Ajv): Ajv {
|
|
47
50
|
return (
|
|
48
51
|
ajv
|
|
@@ -56,15 +59,25 @@ function addCustomAjvFormats(ajv: Ajv): Ajv {
|
|
|
56
59
|
.addFormat('unixTimestamp', {
|
|
57
60
|
type: 'number',
|
|
58
61
|
validate: (n: number) => {
|
|
59
|
-
|
|
60
|
-
|
|
62
|
+
return n >= 0 && n < TS_2500
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
.addFormat('unixTimestamp2000', {
|
|
66
|
+
type: 'number',
|
|
67
|
+
validate: (n: number) => {
|
|
68
|
+
return n >= TS_2000 && n < TS_2500
|
|
61
69
|
},
|
|
62
70
|
})
|
|
63
71
|
.addFormat('unixTimestampMillis', {
|
|
64
72
|
type: 'number',
|
|
65
73
|
validate: (n: number) => {
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
return n >= 0 && n < TS_2500 * 1000
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
.addFormat('unixTimestampMillis2000', {
|
|
78
|
+
type: 'number',
|
|
79
|
+
validate: (n: number) => {
|
|
80
|
+
return n >= TS_2000 * 1000 && n < TS_2500 * 1000
|
|
68
81
|
},
|
|
69
82
|
})
|
|
70
83
|
.addFormat('utcOffset', {
|