@finsys/core 1.0.1 → 1.1.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.
- package/dist/catalogs.d.ts +13 -0
- package/dist/catalogs.js +35 -0
- package/dist/catalogs.test.d.ts +1 -0
- package/dist/catalogs.test.js +207 -0
- package/dist/data/form-field-base-specs.json +7353 -0
- package/dist/data/form-field-types.json +83 -0
- package/dist/data/form-field-validators.json +341 -0
- package/dist/form-field-category.d.ts +12 -0
- package/dist/form-field-category.js +21 -0
- package/dist/form-field-validator.d.ts +18 -0
- package/dist/form-field-validator.js +41 -0
- package/dist/form-field.d.ts +81 -0
- package/dist/form-field.js +197 -0
- package/dist/form-field.test.d.ts +1 -0
- package/dist/form-field.test.js +482 -0
- package/dist/form-spec.d.ts +39 -0
- package/dist/form-spec.js +278 -0
- package/dist/form-spec.test.d.ts +1 -0
- package/dist/form-spec.test.js +322 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/package.json +4 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"types": [
|
|
4
|
+
{
|
|
5
|
+
"displayName": "Text",
|
|
6
|
+
"name": "text"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"displayName": "Number",
|
|
10
|
+
"name": "number"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"displayName": "Email",
|
|
14
|
+
"name": "email"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"displayName": "Dropdown",
|
|
18
|
+
"name": "dropdown"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"displayName": "Checkbox",
|
|
22
|
+
"name": "checkbox"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"displayName": "Radio Group",
|
|
26
|
+
"name": "radiogroup"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"displayName": "Boolean",
|
|
30
|
+
"name": "boolean"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"displayName": "File",
|
|
34
|
+
"name": "file"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"displayName": "Slider",
|
|
38
|
+
"name": "slider"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"displayName": "Range",
|
|
42
|
+
"name": "range"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"displayName": "Long Text (Comment)",
|
|
46
|
+
"name": "comment"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"displayName": "HTML Content",
|
|
50
|
+
"name": "html"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"input_types": [
|
|
54
|
+
{
|
|
55
|
+
"displayName": "Text",
|
|
56
|
+
"name": "text"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"displayName": "Number",
|
|
60
|
+
"name": "number"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"displayName": "Email",
|
|
64
|
+
"name": "email"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"displayName": "Tel",
|
|
68
|
+
"name": "tel"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"displayName": "Date",
|
|
72
|
+
"name": "date"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"displayName": "Password",
|
|
76
|
+
"name": "password"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"displayName": "URL",
|
|
80
|
+
"name": "url"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
}
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"options": [
|
|
4
|
+
{
|
|
5
|
+
"id": 1,
|
|
6
|
+
"displayName": "Numeric Validator",
|
|
7
|
+
"class": "NumericValidator",
|
|
8
|
+
"description": "Ensures the answer is a number within the specified range of minValue and maxValue.",
|
|
9
|
+
"isRequired": true,
|
|
10
|
+
"validators": [
|
|
11
|
+
{
|
|
12
|
+
"type": "numeric",
|
|
13
|
+
"text": "Value must be within the range of 0 to 100",
|
|
14
|
+
"minValue": 0,
|
|
15
|
+
"maxValue": 100
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": 2,
|
|
21
|
+
"displayName": "Text Length Validator",
|
|
22
|
+
"class": "TextValidator",
|
|
23
|
+
"description": "Confirms the length of entered text is between minLength and maxLength.",
|
|
24
|
+
"isRequired": true,
|
|
25
|
+
"validators": [
|
|
26
|
+
{
|
|
27
|
+
"type": "text",
|
|
28
|
+
"minLength": 10,
|
|
29
|
+
"maxLength": 280
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": 3,
|
|
35
|
+
"displayName": "Regex Validator",
|
|
36
|
+
"class": "RegexValidator",
|
|
37
|
+
"description": "Throws an error if an entered value does not match a regular expression defined in the regex property.",
|
|
38
|
+
"isRequired": true,
|
|
39
|
+
"validators": [
|
|
40
|
+
{
|
|
41
|
+
"type": "regex",
|
|
42
|
+
"text": "The value must match the required pattern.",
|
|
43
|
+
"regex": "your-regex-pattern-here"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": 4,
|
|
49
|
+
"displayName": "Email Validator",
|
|
50
|
+
"class": "EmailValidator",
|
|
51
|
+
"description": "Confirms that the entered value is a valid e-mail address.",
|
|
52
|
+
"isRequired": true,
|
|
53
|
+
"validators": [
|
|
54
|
+
{
|
|
55
|
+
"type": "email",
|
|
56
|
+
"text": "Value must be a valid email"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"id": 5,
|
|
62
|
+
"displayName": "Expression Validator",
|
|
63
|
+
"class": "ExpressionValidator",
|
|
64
|
+
"isRequired": true,
|
|
65
|
+
"description": "Ensures that the field's expression always evaluates to true.",
|
|
66
|
+
"validators": [
|
|
67
|
+
{
|
|
68
|
+
"type": "expression",
|
|
69
|
+
"expression": "{fields} = true",
|
|
70
|
+
"text": "The value must be true and cannot be false."
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": 6,
|
|
76
|
+
"displayName": "Answer Count Validator",
|
|
77
|
+
"class": "AnswerCountValidator",
|
|
78
|
+
"isRequired": true,
|
|
79
|
+
"description": "Ensures selection of an appropriate number of choices, keeping responses within the minCount and maxCount range.",
|
|
80
|
+
"validators": [
|
|
81
|
+
{
|
|
82
|
+
"type": "answercount",
|
|
83
|
+
"minCount": 2,
|
|
84
|
+
"maxCount": 4
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"id": 7,
|
|
90
|
+
"displayName": "Full Name Regex Validator",
|
|
91
|
+
"class": "RegexValidator",
|
|
92
|
+
"isRequired": true,
|
|
93
|
+
"description": "Ensures that the entered value is a valid full name.",
|
|
94
|
+
"validators": [
|
|
95
|
+
{
|
|
96
|
+
"type": "regex",
|
|
97
|
+
"text": "Please make sure the name doesn't include extra spaces, numbers, or invalid symbols",
|
|
98
|
+
"regex": "^[A-Za-z'-]+(?:\\s[A-Za-z'-]+)*\\s?[A-Za-z'-]+$"
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": 8,
|
|
104
|
+
"displayName": "Mobile Phone No Regex Validator",
|
|
105
|
+
"class": "RegexValidator",
|
|
106
|
+
"isRequired": true,
|
|
107
|
+
"description": "Ensures valid Malaysia phone number is entered.",
|
|
108
|
+
"validators": [
|
|
109
|
+
{
|
|
110
|
+
"type": "regex",
|
|
111
|
+
"text": "A valid Malaysia phone number is required.",
|
|
112
|
+
"regex": "^(011[0-9]{8}|01[2346789][0-9]{7}|[2-9][0-9]{0,8})$"
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"id": 9,
|
|
118
|
+
"displayName": "IC Number Total Digits Regex Validator",
|
|
119
|
+
"class": "RegexValidator",
|
|
120
|
+
"isRequired": true,
|
|
121
|
+
"description": "Ensures exactly 12 digits are entered for the IC number.",
|
|
122
|
+
"validators": [
|
|
123
|
+
{
|
|
124
|
+
"type": "regex",
|
|
125
|
+
"regex": "^\\d{12}$",
|
|
126
|
+
"text": "Please enter exactly 12 digits numbers"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"id": 10,
|
|
132
|
+
"displayName": "IC Number Valid Birth Year, Month, and Date Regex Validator",
|
|
133
|
+
"class": "RegexValidator",
|
|
134
|
+
"isRequired": true,
|
|
135
|
+
"description": "Ensures valid birth year, month, and day are entered for the IC number.",
|
|
136
|
+
"validators": [
|
|
137
|
+
{
|
|
138
|
+
"type": "regex",
|
|
139
|
+
"regex": "^(\\d{2})(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])\\d{6}$",
|
|
140
|
+
"text": "First 6 digits must be valid birth year (00-99), month (01-12), and day (01-31)"
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": 11,
|
|
146
|
+
"displayName": "Duration in Current Residence (Months) Regex Validator",
|
|
147
|
+
"class": "RegexValidator",
|
|
148
|
+
"isRequired": true,
|
|
149
|
+
"description": "Ensures duration includes a number between 0-11.",
|
|
150
|
+
"validators": [
|
|
151
|
+
{
|
|
152
|
+
"type": "regex",
|
|
153
|
+
"regex": "^([0-9]|10|11)$",
|
|
154
|
+
"text": "Value must be a number between 0-11."
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"id": 12,
|
|
160
|
+
"displayName": "Duration in Current Residence (Years) Regex Validator",
|
|
161
|
+
"class": "RegexValidator",
|
|
162
|
+
"isRequired": true,
|
|
163
|
+
"description": "Ensures duration includes a number between 0-99.",
|
|
164
|
+
"validators": [
|
|
165
|
+
{
|
|
166
|
+
"type": "regex",
|
|
167
|
+
"regex": "^([0-9]|[1-9][0-9])$",
|
|
168
|
+
"text": "Value must be a number between 0-99."
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": 13,
|
|
174
|
+
"displayName": "Office Phone No. Regex Validator",
|
|
175
|
+
"class": "RegexValidator",
|
|
176
|
+
"isRequired": true,
|
|
177
|
+
"description": "Ensures office phone number is entered in the correct format.",
|
|
178
|
+
"validators": [
|
|
179
|
+
{
|
|
180
|
+
"type": "regex",
|
|
181
|
+
"text": "The phone number must be a valid Malaysian number",
|
|
182
|
+
"regex": "^(011[0-9]{8}|(60[4-7]|004|005|006|007|009|609|012|013|014|016|017|019)[0-9]{7})$"
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"id": 14,
|
|
188
|
+
"displayName": "Age Regex Validator",
|
|
189
|
+
"class": "RegexValidator",
|
|
190
|
+
"isRequired": true,
|
|
191
|
+
"description": "Ensures age entered is between 21-55.",
|
|
192
|
+
"validators": [
|
|
193
|
+
{
|
|
194
|
+
"type": "regex",
|
|
195
|
+
"text": "Please enter a valid whole number age between 21 and 55.",
|
|
196
|
+
"regex": "^(2[1-9]|[3-4][0-9]|55)$"
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"id": 15,
|
|
202
|
+
"displayName": "Consent(s) Expression Validator",
|
|
203
|
+
"class": "ExpressionValidator",
|
|
204
|
+
"isRequired": true,
|
|
205
|
+
"description": "Ensures that the field's expression always evaluates to true.",
|
|
206
|
+
"validators": [
|
|
207
|
+
{
|
|
208
|
+
"type": "expression",
|
|
209
|
+
"expression": "{consentCrossSelling} = true",
|
|
210
|
+
"text": "You must provide consent to Consent Cross-Selling."
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"id": 16,
|
|
216
|
+
"displayName": "Date Joined Regex Validator",
|
|
217
|
+
"class": "RegexValidator",
|
|
218
|
+
"isRequired": true,
|
|
219
|
+
"description": "Ensures date joined is in the correct format.",
|
|
220
|
+
"validators": [
|
|
221
|
+
{
|
|
222
|
+
"type": "regex",
|
|
223
|
+
"regex": "^\\d{4}-\\d{2}-\\d{2}$",
|
|
224
|
+
"text": "Date must be in YYYY-MM-DD format"
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
"id": 17,
|
|
230
|
+
"displayName": "Date Joined Custom Validator",
|
|
231
|
+
"class": "CustomValidator",
|
|
232
|
+
"isRequired": true,
|
|
233
|
+
"description": "Ensures date joined is not in the future.",
|
|
234
|
+
"validators": [
|
|
235
|
+
{
|
|
236
|
+
"type": "custom",
|
|
237
|
+
"validator": "validateNotFutureDate",
|
|
238
|
+
"text": "Date of joining cannot be in the future"
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"id": 18,
|
|
244
|
+
"displayName": "Emergency Contact No. Regex Validator",
|
|
245
|
+
"class": "RegexValidator",
|
|
246
|
+
"isRequired": true,
|
|
247
|
+
"description": "Ensures emergency contact number is entered in the correct format.",
|
|
248
|
+
"validators": [
|
|
249
|
+
{
|
|
250
|
+
"type": "regex",
|
|
251
|
+
"text": "A valid Malaysia phone number is required.",
|
|
252
|
+
"regex": "^((60[4-79]|0[4-79])[0-9]{7}|011[0-9]{8}|01[2346789][0-9]{7})$"
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
"id": 19,
|
|
258
|
+
"displayName": "Monthly Gross Income Regex Validator",
|
|
259
|
+
"class": "RegexValidator",
|
|
260
|
+
"isRequired": true,
|
|
261
|
+
"description": "Ensures monthly gross income is entered in the correct format.",
|
|
262
|
+
"validators": [
|
|
263
|
+
{
|
|
264
|
+
"type": "regex",
|
|
265
|
+
"regex": "^\\d+(\\.\\d+)?$",
|
|
266
|
+
"text": "Please enter a valid non-negative number."
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"id": 20,
|
|
272
|
+
"displayName": "Monthly Gross Income Expression Validator",
|
|
273
|
+
"class": "ExpressionValidator",
|
|
274
|
+
"isRequired": true,
|
|
275
|
+
"description": "Ensures monthly gross income is at least RM 2000.",
|
|
276
|
+
"validators": [
|
|
277
|
+
{
|
|
278
|
+
"type": "expression",
|
|
279
|
+
"expression": "{monthlyGrossIncome} >= 2000",
|
|
280
|
+
"text": "Income must be at least RM 2000."
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"id": 21,
|
|
286
|
+
"displayName": "No of Dependants Regex Validator",
|
|
287
|
+
"class": "RegexValidator",
|
|
288
|
+
"isRequired": true,
|
|
289
|
+
"description": "Ensures number of dependants is entered in the correct format.",
|
|
290
|
+
"validators": [
|
|
291
|
+
{
|
|
292
|
+
"type": "regex",
|
|
293
|
+
"text": "Please enter a valid whole number between 0 and 99.",
|
|
294
|
+
"regex": "^[0-9][0-9]?$"
|
|
295
|
+
}
|
|
296
|
+
]
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"id": 22,
|
|
300
|
+
"displayName": "Financing Tenure (Years) Regex Validator",
|
|
301
|
+
"class": "RegexValidator",
|
|
302
|
+
"isRequired": true,
|
|
303
|
+
"description": "Ensures financing tenure is entered in the correct format.",
|
|
304
|
+
"validators": [
|
|
305
|
+
{
|
|
306
|
+
"type": "regex",
|
|
307
|
+
"text": "Please enter a valid financing tenure from 1 to 7 years.",
|
|
308
|
+
"regex": "^[1-7]$"
|
|
309
|
+
}
|
|
310
|
+
]
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
"id": 23,
|
|
314
|
+
"displayName": "Financing Amount Range Regex Validator",
|
|
315
|
+
"class": "RegexValidator",
|
|
316
|
+
"isRequired": true,
|
|
317
|
+
"description": "Ensures financing amount is entered in the correct format.",
|
|
318
|
+
"validators": [
|
|
319
|
+
{
|
|
320
|
+
"type": "regex",
|
|
321
|
+
"text": "Please enter a financing amount between 2,000 and 150,000.",
|
|
322
|
+
"regex": "^(2000|[1-9][0-9]{3}|[1-9][0-9]{4}|150000)$"
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
"id": 24,
|
|
328
|
+
"displayName": "Financing Amount Incrementals Regex Validator",
|
|
329
|
+
"class": "RegexValidator",
|
|
330
|
+
"isRequired": true,
|
|
331
|
+
"description": "Ensures financing amount is entered incrementally in the correct format.",
|
|
332
|
+
"validators": [
|
|
333
|
+
{
|
|
334
|
+
"type": "regex",
|
|
335
|
+
"text": "Please enter an amount in increments of 1,000.",
|
|
336
|
+
"regex": "^([1-9][0-9]*000|150000)$"
|
|
337
|
+
}
|
|
338
|
+
]
|
|
339
|
+
}
|
|
340
|
+
]
|
|
341
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export class FormFieldCategory {
|
|
2
|
+
constructor(id, name) {
|
|
3
|
+
this._id = String(id);
|
|
4
|
+
this._name = name;
|
|
5
|
+
}
|
|
6
|
+
get id() {
|
|
7
|
+
return this._id;
|
|
8
|
+
}
|
|
9
|
+
get name() {
|
|
10
|
+
return this._name;
|
|
11
|
+
}
|
|
12
|
+
set name(value) {
|
|
13
|
+
this._name = value;
|
|
14
|
+
}
|
|
15
|
+
toJSON() {
|
|
16
|
+
return {
|
|
17
|
+
id: this._id,
|
|
18
|
+
name: this._name,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Validator } from "./survey-generator.js";
|
|
2
|
+
import type { EditorValidator } from "./form-field.js";
|
|
3
|
+
export interface FormValidatorDefinitions {
|
|
4
|
+
options: EditorValidator[];
|
|
5
|
+
version: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class FormFieldValidator implements EditorValidator {
|
|
8
|
+
id: number;
|
|
9
|
+
displayName: string;
|
|
10
|
+
class: string;
|
|
11
|
+
description: string;
|
|
12
|
+
isRequired: boolean;
|
|
13
|
+
validators: Validator[];
|
|
14
|
+
constructor(validatorData: EditorValidator);
|
|
15
|
+
validate(value: any): boolean;
|
|
16
|
+
private validateNumeric;
|
|
17
|
+
private validateText;
|
|
18
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export class FormFieldValidator {
|
|
2
|
+
constructor(validatorData) {
|
|
3
|
+
this.id = validatorData.id;
|
|
4
|
+
this.displayName = validatorData.displayName;
|
|
5
|
+
this.class = validatorData.class;
|
|
6
|
+
this.description = validatorData.description;
|
|
7
|
+
this.isRequired = validatorData.isRequired;
|
|
8
|
+
this.validators = validatorData.validators;
|
|
9
|
+
}
|
|
10
|
+
validate(value) {
|
|
11
|
+
for (const validator of this.validators) {
|
|
12
|
+
switch (validator.type) {
|
|
13
|
+
case 'numeric':
|
|
14
|
+
if (!this.validateNumeric(value, validator.minValue, validator.maxValue)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case 'text':
|
|
19
|
+
if (!this.validateText(value, validator.minLength, validator.maxLength)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
validateNumeric(value, min, max) {
|
|
28
|
+
if (min !== undefined && value < min)
|
|
29
|
+
return false;
|
|
30
|
+
if (max !== undefined && value > max)
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
validateText(value, minLength, maxLength) {
|
|
35
|
+
if (minLength !== undefined && value.length < minLength)
|
|
36
|
+
return false;
|
|
37
|
+
if (maxLength !== undefined && value.length > maxLength)
|
|
38
|
+
return false;
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { FieldData, Choice, Validator } from "./survey-generator.js";
|
|
2
|
+
export declare enum FieldType {
|
|
3
|
+
FILE = "file",
|
|
4
|
+
TEXT = "text",
|
|
5
|
+
DROPDOWN = "dropdown",
|
|
6
|
+
BOOLEAN = "boolean",
|
|
7
|
+
CHECKBOX = "checkbox",
|
|
8
|
+
RADIOGROUP = "radiogroup",
|
|
9
|
+
SLIDER = "slider",
|
|
10
|
+
HTML = "html",
|
|
11
|
+
TAGBOX = "tagbox",
|
|
12
|
+
NUMBER = "number",
|
|
13
|
+
EMAIL = "email",
|
|
14
|
+
COMMENT = "comment",
|
|
15
|
+
RANGE = "range",
|
|
16
|
+
UNKNOWN = "unknown"
|
|
17
|
+
}
|
|
18
|
+
export interface FormFieldType {
|
|
19
|
+
name: string;
|
|
20
|
+
displayName: string;
|
|
21
|
+
}
|
|
22
|
+
export interface FormFieldInputType {
|
|
23
|
+
name: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
}
|
|
26
|
+
export interface FormFieldTypeDefinitions {
|
|
27
|
+
version: number;
|
|
28
|
+
types: FormFieldType[];
|
|
29
|
+
input_types: FormFieldInputType[];
|
|
30
|
+
}
|
|
31
|
+
export interface DropdownOption {
|
|
32
|
+
id: number;
|
|
33
|
+
name: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
choices: Choice[];
|
|
36
|
+
}
|
|
37
|
+
export interface EditorValidator {
|
|
38
|
+
id: number;
|
|
39
|
+
displayName: string;
|
|
40
|
+
class: string;
|
|
41
|
+
description: string;
|
|
42
|
+
isRequired: boolean;
|
|
43
|
+
validators: Validator[];
|
|
44
|
+
}
|
|
45
|
+
export default abstract class FormField {
|
|
46
|
+
fieldObject: FieldData;
|
|
47
|
+
constructor(name: string, displayName: string, type: string, category: string);
|
|
48
|
+
static fromObject(fieldObject: FieldData): FormField;
|
|
49
|
+
abstract getFieldNames(): string[];
|
|
50
|
+
protected cleanObject(obj: any): any;
|
|
51
|
+
toJSON(): any;
|
|
52
|
+
get displayName(): string;
|
|
53
|
+
set displayName(newDisplayName: string);
|
|
54
|
+
get name(): string;
|
|
55
|
+
get type(): FieldType;
|
|
56
|
+
get inputType(): string;
|
|
57
|
+
get categoryId(): string;
|
|
58
|
+
set categoryId(categoryId: string);
|
|
59
|
+
get defaultValue(): any;
|
|
60
|
+
set defaultValue(value: any);
|
|
61
|
+
get placeholder(): string | undefined;
|
|
62
|
+
get validators(): Validator[] | undefined;
|
|
63
|
+
get choices(): Choice[];
|
|
64
|
+
set choices(choices: Choice[]);
|
|
65
|
+
get visible(): boolean;
|
|
66
|
+
get visibleIf(): string | undefined;
|
|
67
|
+
get isRequired(): boolean;
|
|
68
|
+
get startWithNewLine(): boolean;
|
|
69
|
+
get requiredForEvaluation(): boolean;
|
|
70
|
+
get maxLength(): number | undefined;
|
|
71
|
+
get min(): number | undefined;
|
|
72
|
+
get max(): number | undefined;
|
|
73
|
+
}
|
|
74
|
+
export declare class BasicFormField extends FormField {
|
|
75
|
+
constructor(name: string, displayName: string, type: string, category: string);
|
|
76
|
+
getFieldNames(): string[];
|
|
77
|
+
}
|
|
78
|
+
export declare class FileFormField extends FormField {
|
|
79
|
+
constructor(name: string, displayName: string, type: string, category: string, ihs_column_names: string[]);
|
|
80
|
+
getFieldNames(): string[];
|
|
81
|
+
}
|