nodester 0.3.2 → 0.3.4
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.
|
@@ -7,12 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
module.exports = {
|
|
10
|
+
CHAR: _STRING,
|
|
11
|
+
VARCHAR: _STRING,
|
|
12
|
+
|
|
10
13
|
NUMBER: _NUMBER,
|
|
11
|
-
|
|
14
|
+
|
|
15
|
+
INT: _INTEGER,
|
|
16
|
+
INTEGER: _INTEGER,
|
|
17
|
+
|
|
12
18
|
BOOLEAN: _BOOLEAN,
|
|
19
|
+
|
|
13
20
|
STRING: _STRING,
|
|
21
|
+
TEXT: _TEXT,
|
|
14
22
|
|
|
15
23
|
DATE: _DATE,
|
|
24
|
+
DATETIME: _DATE,
|
|
16
25
|
|
|
17
26
|
JSON: _JSON
|
|
18
27
|
}
|
|
@@ -39,7 +48,7 @@ function _NUMBER(value=undefined, options={ fallback:undefined, min:undefined, m
|
|
|
39
48
|
}
|
|
40
49
|
}
|
|
41
50
|
|
|
42
|
-
function
|
|
51
|
+
function _INTEGER(value=undefined, options={ fallback:undefined, min:undefined, max:undefined }) {
|
|
43
52
|
const num = _NUMBER(value, { fallback:undefined, min:options?.min, max:options?.max });
|
|
44
53
|
return num === undefined ? options?.fallback : parseInt(num);
|
|
45
54
|
}
|
|
@@ -73,6 +82,18 @@ function _STRING(value=undefined, options={ fallback:undefined }) {
|
|
|
73
82
|
}
|
|
74
83
|
}
|
|
75
84
|
|
|
85
|
+
function _TEXT(value=undefined, options={ fallback:undefined }) {
|
|
86
|
+
try {
|
|
87
|
+
if (typeof value !== 'string')
|
|
88
|
+
throw new Error(`Not a String`);
|
|
89
|
+
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
catch(ex) {
|
|
93
|
+
return options?.fallback;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
76
97
|
function _DATE(value=undefined, options={ fallback:undefined }) {
|
|
77
98
|
try {
|
|
78
99
|
const type = Object.prototype.toString.call(value);
|