@opencrvs/toolkit 2.1.0-rc.69ab488 → 2.1.0-rc.6c5b938
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/application-config/index.js +2 -1
- package/dist/cli.js +0 -48
- package/dist/commons/api/router.d.ts +147 -183
- package/dist/commons/conditionals/conditionals.d.ts +1586 -34
- package/dist/commons/events/ActionConfig.d.ts +7 -0
- package/dist/commons/events/ActionDocument.d.ts +6 -6
- package/dist/commons/events/ActionInput.d.ts +0 -6
- package/dist/commons/events/EventDocument.d.ts +2 -2
- package/dist/commons/events/field.d.ts +722 -34
- package/dist/commons/events/test.utils.d.ts +0 -3
- package/dist/commons/events/utils.d.ts +11 -3
- package/dist/environment/derived-variables.d.ts +0 -12
- package/dist/environment/derived-variables.d.ts.map +1 -1
- package/dist/environment/derived-variables.js +0 -14
- package/dist/environment/logger.d.ts +3 -12
- package/dist/environment/logger.d.ts.map +1 -1
- package/dist/environment/manage-users.js +17 -7
- package/dist/environment/setup-environment.js +0 -14
- package/dist/environment/swarm-to-k8s.js +17 -7
- package/dist/environment/update-workflows.js +17 -7
- package/dist/environment/users.js +17 -7
- package/dist/environment/utils.js +17 -7
- package/dist/events/index.js +32 -18
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
- package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
- package/dist/notification/index.js +18 -16
- package/dist/templates/charts-values/dependencies/values.yaml +0 -3
- package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
- package/opencrvs-toolkit-2.1.0-rc.6c5b938.tgz +0 -0
- package/package.json +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.1.0-rc.69ab488.tgz +0 -0
|
@@ -138,17 +138,601 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
138
138
|
* @private Internal property used for field reference tracking.
|
|
139
139
|
*/
|
|
140
140
|
$$field: string;
|
|
141
|
-
get(fieldPath: string): any;
|
|
141
|
+
get(fieldPath: string): /*elided*/ any;
|
|
142
142
|
getByPath(fieldPath: string[]): {
|
|
143
143
|
$$subfield: string[];
|
|
144
144
|
/**
|
|
145
145
|
* @private Internal property used for field reference tracking.
|
|
146
146
|
*/
|
|
147
147
|
$$field: string;
|
|
148
|
-
get(fieldPath: string): any;
|
|
149
|
-
getByPath(fieldPath: string[]): any;
|
|
150
|
-
asDob():
|
|
151
|
-
|
|
148
|
+
get(fieldPath: string): /*elided*/ any;
|
|
149
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
150
|
+
asDob(): {
|
|
151
|
+
$$subfield: string[];
|
|
152
|
+
/**
|
|
153
|
+
* @private Internal property used for field reference tracking.
|
|
154
|
+
*/
|
|
155
|
+
$$field: string;
|
|
156
|
+
get(fieldPath: string): /*elided*/ any;
|
|
157
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
158
|
+
asDob(): /*elided*/ any;
|
|
159
|
+
asAge(): /*elided*/ any;
|
|
160
|
+
isAfter(): {
|
|
161
|
+
days: (days: number) => {
|
|
162
|
+
inPast: () => JSONSchema;
|
|
163
|
+
inFuture: () => JSONSchema;
|
|
164
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
165
|
+
fromNow: () => JSONSchema;
|
|
166
|
+
};
|
|
167
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
168
|
+
now: () => JSONSchema;
|
|
169
|
+
};
|
|
170
|
+
isBefore(): {
|
|
171
|
+
days: (days: number) => {
|
|
172
|
+
inPast: () => JSONSchema;
|
|
173
|
+
inFuture: () => JSONSchema;
|
|
174
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
175
|
+
fromNow: () => JSONSchema;
|
|
176
|
+
};
|
|
177
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
178
|
+
now: () => JSONSchema;
|
|
179
|
+
};
|
|
180
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
181
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
182
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
183
|
+
/**
|
|
184
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
185
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
186
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
187
|
+
*
|
|
188
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
191
|
+
isFalsy(): JSONSchema;
|
|
192
|
+
isUndefined(): JSONSchema;
|
|
193
|
+
inArray(values: string[]): JSONSchema;
|
|
194
|
+
isValidEnglishName(): JSONSchema;
|
|
195
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
196
|
+
/**
|
|
197
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
198
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
199
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
200
|
+
*/
|
|
201
|
+
matches(pattern: string): JSONSchema;
|
|
202
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
203
|
+
getId: () => {
|
|
204
|
+
fieldId: string;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* @deprecated
|
|
208
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
209
|
+
* with 'and' combinator e.g.
|
|
210
|
+
* and(
|
|
211
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
212
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
213
|
+
* )
|
|
214
|
+
*/
|
|
215
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
216
|
+
/**
|
|
217
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
218
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
219
|
+
* available inside the function body — all logic must be self-contained.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* field('nid').customClientValidator((value) => {
|
|
223
|
+
* // LUHN check — all logic must be inline
|
|
224
|
+
* const digits = String(value).split('').map(Number)
|
|
225
|
+
* // ...
|
|
226
|
+
* return isValid
|
|
227
|
+
* })
|
|
228
|
+
*/
|
|
229
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
230
|
+
/**
|
|
231
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
232
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
233
|
+
* The function receives the referenced field's value as the first argument and
|
|
234
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
235
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
236
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
237
|
+
*
|
|
238
|
+
* For computing a default value without referencing a specific field, use
|
|
239
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
243
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
244
|
+
* )
|
|
245
|
+
*/
|
|
246
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
247
|
+
};
|
|
248
|
+
asAge(): {
|
|
249
|
+
$$subfield: string[];
|
|
250
|
+
/**
|
|
251
|
+
* @private Internal property used for field reference tracking.
|
|
252
|
+
*/
|
|
253
|
+
$$field: string;
|
|
254
|
+
get(fieldPath: string): /*elided*/ any;
|
|
255
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
256
|
+
asDob(): /*elided*/ any;
|
|
257
|
+
asAge(): /*elided*/ any;
|
|
258
|
+
isAfter(): {
|
|
259
|
+
days: (days: number) => {
|
|
260
|
+
inPast: () => JSONSchema;
|
|
261
|
+
inFuture: () => JSONSchema;
|
|
262
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
263
|
+
fromNow: () => JSONSchema;
|
|
264
|
+
};
|
|
265
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
266
|
+
now: () => JSONSchema;
|
|
267
|
+
};
|
|
268
|
+
isBefore(): {
|
|
269
|
+
days: (days: number) => {
|
|
270
|
+
inPast: () => JSONSchema;
|
|
271
|
+
inFuture: () => JSONSchema;
|
|
272
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
273
|
+
fromNow: () => JSONSchema;
|
|
274
|
+
};
|
|
275
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
276
|
+
now: () => JSONSchema;
|
|
277
|
+
};
|
|
278
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
279
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
280
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
281
|
+
/**
|
|
282
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
283
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
284
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
285
|
+
*
|
|
286
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
287
|
+
*
|
|
288
|
+
*/
|
|
289
|
+
isFalsy(): JSONSchema;
|
|
290
|
+
isUndefined(): JSONSchema;
|
|
291
|
+
inArray(values: string[]): JSONSchema;
|
|
292
|
+
isValidEnglishName(): JSONSchema;
|
|
293
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
294
|
+
/**
|
|
295
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
296
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
297
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
298
|
+
*/
|
|
299
|
+
matches(pattern: string): JSONSchema;
|
|
300
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
301
|
+
getId: () => {
|
|
302
|
+
fieldId: string;
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* @deprecated
|
|
306
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
307
|
+
* with 'and' combinator e.g.
|
|
308
|
+
* and(
|
|
309
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
310
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
311
|
+
* )
|
|
312
|
+
*/
|
|
313
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
314
|
+
/**
|
|
315
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
316
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
317
|
+
* available inside the function body — all logic must be self-contained.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* field('nid').customClientValidator((value) => {
|
|
321
|
+
* // LUHN check — all logic must be inline
|
|
322
|
+
* const digits = String(value).split('').map(Number)
|
|
323
|
+
* // ...
|
|
324
|
+
* return isValid
|
|
325
|
+
* })
|
|
326
|
+
*/
|
|
327
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
328
|
+
/**
|
|
329
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
330
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
331
|
+
* The function receives the referenced field's value as the first argument and
|
|
332
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
333
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
334
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
335
|
+
*
|
|
336
|
+
* For computing a default value without referencing a specific field, use
|
|
337
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
341
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
342
|
+
* )
|
|
343
|
+
*/
|
|
344
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
345
|
+
};
|
|
346
|
+
isAfter(): {
|
|
347
|
+
days: (days: number) => {
|
|
348
|
+
inPast: () => JSONSchema;
|
|
349
|
+
inFuture: () => JSONSchema;
|
|
350
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
351
|
+
fromNow: () => JSONSchema;
|
|
352
|
+
};
|
|
353
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
354
|
+
now: () => JSONSchema;
|
|
355
|
+
};
|
|
356
|
+
isBefore(): {
|
|
357
|
+
days: (days: number) => {
|
|
358
|
+
inPast: () => JSONSchema;
|
|
359
|
+
inFuture: () => JSONSchema;
|
|
360
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
361
|
+
fromNow: () => JSONSchema;
|
|
362
|
+
};
|
|
363
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
364
|
+
now: () => JSONSchema;
|
|
365
|
+
};
|
|
366
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
367
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
368
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
369
|
+
/**
|
|
370
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
371
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
372
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
373
|
+
*
|
|
374
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
375
|
+
*
|
|
376
|
+
*/
|
|
377
|
+
isFalsy(): JSONSchema;
|
|
378
|
+
isUndefined(): JSONSchema;
|
|
379
|
+
inArray(values: string[]): JSONSchema;
|
|
380
|
+
isValidEnglishName(): JSONSchema;
|
|
381
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
382
|
+
/**
|
|
383
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
384
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
385
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
386
|
+
*/
|
|
387
|
+
matches(pattern: string): JSONSchema;
|
|
388
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
389
|
+
getId: () => {
|
|
390
|
+
fieldId: string;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* @deprecated
|
|
394
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
395
|
+
* with 'and' combinator e.g.
|
|
396
|
+
* and(
|
|
397
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
398
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
399
|
+
* )
|
|
400
|
+
*/
|
|
401
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
402
|
+
/**
|
|
403
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
404
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
405
|
+
* available inside the function body — all logic must be self-contained.
|
|
406
|
+
*
|
|
407
|
+
* @example
|
|
408
|
+
* field('nid').customClientValidator((value) => {
|
|
409
|
+
* // LUHN check — all logic must be inline
|
|
410
|
+
* const digits = String(value).split('').map(Number)
|
|
411
|
+
* // ...
|
|
412
|
+
* return isValid
|
|
413
|
+
* })
|
|
414
|
+
*/
|
|
415
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
416
|
+
/**
|
|
417
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
418
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
419
|
+
* The function receives the referenced field's value as the first argument and
|
|
420
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
421
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
422
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
423
|
+
*
|
|
424
|
+
* For computing a default value without referencing a specific field, use
|
|
425
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
426
|
+
*
|
|
427
|
+
* @example
|
|
428
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
429
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
430
|
+
* )
|
|
431
|
+
*/
|
|
432
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
433
|
+
};
|
|
434
|
+
asDob(): {
|
|
435
|
+
$$subfield: string[];
|
|
436
|
+
/**
|
|
437
|
+
* @private Internal property used for field reference tracking.
|
|
438
|
+
*/
|
|
439
|
+
$$field: string;
|
|
440
|
+
get(fieldPath: string): /*elided*/ any;
|
|
441
|
+
getByPath(fieldPath: string[]): {
|
|
442
|
+
$$subfield: string[];
|
|
443
|
+
/**
|
|
444
|
+
* @private Internal property used for field reference tracking.
|
|
445
|
+
*/
|
|
446
|
+
$$field: string;
|
|
447
|
+
get(fieldPath: string): /*elided*/ any;
|
|
448
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
449
|
+
asDob(): /*elided*/ any;
|
|
450
|
+
asAge(): /*elided*/ any;
|
|
451
|
+
isAfter(): {
|
|
452
|
+
days: (days: number) => {
|
|
453
|
+
inPast: () => JSONSchema;
|
|
454
|
+
inFuture: () => JSONSchema;
|
|
455
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
456
|
+
fromNow: () => JSONSchema;
|
|
457
|
+
};
|
|
458
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
459
|
+
now: () => JSONSchema;
|
|
460
|
+
};
|
|
461
|
+
isBefore(): {
|
|
462
|
+
days: (days: number) => {
|
|
463
|
+
inPast: () => JSONSchema;
|
|
464
|
+
inFuture: () => JSONSchema;
|
|
465
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
466
|
+
fromNow: () => JSONSchema;
|
|
467
|
+
};
|
|
468
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
469
|
+
now: () => JSONSchema;
|
|
470
|
+
};
|
|
471
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
472
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
473
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
474
|
+
/**
|
|
475
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
476
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
477
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
478
|
+
*
|
|
479
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
480
|
+
*
|
|
481
|
+
*/
|
|
482
|
+
isFalsy(): JSONSchema;
|
|
483
|
+
isUndefined(): JSONSchema;
|
|
484
|
+
inArray(values: string[]): JSONSchema;
|
|
485
|
+
isValidEnglishName(): JSONSchema;
|
|
486
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
487
|
+
/**
|
|
488
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
489
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
490
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
491
|
+
*/
|
|
492
|
+
matches(pattern: string): JSONSchema;
|
|
493
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
494
|
+
getId: () => {
|
|
495
|
+
fieldId: string;
|
|
496
|
+
};
|
|
497
|
+
/**
|
|
498
|
+
* @deprecated
|
|
499
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
500
|
+
* with 'and' combinator e.g.
|
|
501
|
+
* and(
|
|
502
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
503
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
504
|
+
* )
|
|
505
|
+
*/
|
|
506
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
507
|
+
/**
|
|
508
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
509
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
510
|
+
* available inside the function body — all logic must be self-contained.
|
|
511
|
+
*
|
|
512
|
+
* @example
|
|
513
|
+
* field('nid').customClientValidator((value) => {
|
|
514
|
+
* // LUHN check — all logic must be inline
|
|
515
|
+
* const digits = String(value).split('').map(Number)
|
|
516
|
+
* // ...
|
|
517
|
+
* return isValid
|
|
518
|
+
* })
|
|
519
|
+
*/
|
|
520
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
521
|
+
/**
|
|
522
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
523
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
524
|
+
* The function receives the referenced field's value as the first argument and
|
|
525
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
526
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
527
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
528
|
+
*
|
|
529
|
+
* For computing a default value without referencing a specific field, use
|
|
530
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
534
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
535
|
+
* )
|
|
536
|
+
*/
|
|
537
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
538
|
+
};
|
|
539
|
+
asDob(): /*elided*/ any;
|
|
540
|
+
asAge(): /*elided*/ any;
|
|
541
|
+
isAfter(): {
|
|
542
|
+
days: (days: number) => {
|
|
543
|
+
inPast: () => JSONSchema;
|
|
544
|
+
inFuture: () => JSONSchema;
|
|
545
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
546
|
+
fromNow: () => JSONSchema;
|
|
547
|
+
};
|
|
548
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
549
|
+
now: () => JSONSchema;
|
|
550
|
+
};
|
|
551
|
+
isBefore(): {
|
|
552
|
+
days: (days: number) => {
|
|
553
|
+
inPast: () => JSONSchema;
|
|
554
|
+
inFuture: () => JSONSchema;
|
|
555
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
556
|
+
fromNow: () => JSONSchema;
|
|
557
|
+
};
|
|
558
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
559
|
+
now: () => JSONSchema;
|
|
560
|
+
};
|
|
561
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
562
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
563
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
564
|
+
/**
|
|
565
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
566
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
567
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
568
|
+
*
|
|
569
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
570
|
+
*
|
|
571
|
+
*/
|
|
572
|
+
isFalsy(): JSONSchema;
|
|
573
|
+
isUndefined(): JSONSchema;
|
|
574
|
+
inArray(values: string[]): JSONSchema;
|
|
575
|
+
isValidEnglishName(): JSONSchema;
|
|
576
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
577
|
+
/**
|
|
578
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
579
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
580
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
581
|
+
*/
|
|
582
|
+
matches(pattern: string): JSONSchema;
|
|
583
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
584
|
+
getId: () => {
|
|
585
|
+
fieldId: string;
|
|
586
|
+
};
|
|
587
|
+
/**
|
|
588
|
+
* @deprecated
|
|
589
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
590
|
+
* with 'and' combinator e.g.
|
|
591
|
+
* and(
|
|
592
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
593
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
594
|
+
* )
|
|
595
|
+
*/
|
|
596
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
597
|
+
/**
|
|
598
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
599
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
600
|
+
* available inside the function body — all logic must be self-contained.
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* field('nid').customClientValidator((value) => {
|
|
604
|
+
* // LUHN check — all logic must be inline
|
|
605
|
+
* const digits = String(value).split('').map(Number)
|
|
606
|
+
* // ...
|
|
607
|
+
* return isValid
|
|
608
|
+
* })
|
|
609
|
+
*/
|
|
610
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
611
|
+
/**
|
|
612
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
613
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
614
|
+
* The function receives the referenced field's value as the first argument and
|
|
615
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
616
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
617
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
618
|
+
*
|
|
619
|
+
* For computing a default value without referencing a specific field, use
|
|
620
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
624
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
625
|
+
* )
|
|
626
|
+
*/
|
|
627
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
628
|
+
};
|
|
629
|
+
asAge(): {
|
|
630
|
+
$$subfield: string[];
|
|
631
|
+
/**
|
|
632
|
+
* @private Internal property used for field reference tracking.
|
|
633
|
+
*/
|
|
634
|
+
$$field: string;
|
|
635
|
+
get(fieldPath: string): /*elided*/ any;
|
|
636
|
+
getByPath(fieldPath: string[]): {
|
|
637
|
+
$$subfield: string[];
|
|
638
|
+
/**
|
|
639
|
+
* @private Internal property used for field reference tracking.
|
|
640
|
+
*/
|
|
641
|
+
$$field: string;
|
|
642
|
+
get(fieldPath: string): /*elided*/ any;
|
|
643
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
644
|
+
asDob(): /*elided*/ any;
|
|
645
|
+
asAge(): /*elided*/ any;
|
|
646
|
+
isAfter(): {
|
|
647
|
+
days: (days: number) => {
|
|
648
|
+
inPast: () => JSONSchema;
|
|
649
|
+
inFuture: () => JSONSchema;
|
|
650
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
651
|
+
fromNow: () => JSONSchema;
|
|
652
|
+
};
|
|
653
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
654
|
+
now: () => JSONSchema;
|
|
655
|
+
};
|
|
656
|
+
isBefore(): {
|
|
657
|
+
days: (days: number) => {
|
|
658
|
+
inPast: () => JSONSchema;
|
|
659
|
+
inFuture: () => JSONSchema;
|
|
660
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
661
|
+
fromNow: () => JSONSchema;
|
|
662
|
+
};
|
|
663
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
664
|
+
now: () => JSONSchema;
|
|
665
|
+
};
|
|
666
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
667
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
668
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
669
|
+
/**
|
|
670
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
671
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
672
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
673
|
+
*
|
|
674
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
675
|
+
*
|
|
676
|
+
*/
|
|
677
|
+
isFalsy(): JSONSchema;
|
|
678
|
+
isUndefined(): JSONSchema;
|
|
679
|
+
inArray(values: string[]): JSONSchema;
|
|
680
|
+
isValidEnglishName(): JSONSchema;
|
|
681
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
682
|
+
/**
|
|
683
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
684
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
685
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
686
|
+
*/
|
|
687
|
+
matches(pattern: string): JSONSchema;
|
|
688
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
689
|
+
getId: () => {
|
|
690
|
+
fieldId: string;
|
|
691
|
+
};
|
|
692
|
+
/**
|
|
693
|
+
* @deprecated
|
|
694
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
695
|
+
* with 'and' combinator e.g.
|
|
696
|
+
* and(
|
|
697
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
698
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
699
|
+
* )
|
|
700
|
+
*/
|
|
701
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
702
|
+
/**
|
|
703
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
704
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
705
|
+
* available inside the function body — all logic must be self-contained.
|
|
706
|
+
*
|
|
707
|
+
* @example
|
|
708
|
+
* field('nid').customClientValidator((value) => {
|
|
709
|
+
* // LUHN check — all logic must be inline
|
|
710
|
+
* const digits = String(value).split('').map(Number)
|
|
711
|
+
* // ...
|
|
712
|
+
* return isValid
|
|
713
|
+
* })
|
|
714
|
+
*/
|
|
715
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
716
|
+
/**
|
|
717
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
718
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
719
|
+
* The function receives the referenced field's value as the first argument and
|
|
720
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
721
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
722
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
723
|
+
*
|
|
724
|
+
* For computing a default value without referencing a specific field, use
|
|
725
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
726
|
+
*
|
|
727
|
+
* @example
|
|
728
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
729
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
730
|
+
* )
|
|
731
|
+
*/
|
|
732
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
733
|
+
};
|
|
734
|
+
asDob(): /*elided*/ any;
|
|
735
|
+
asAge(): /*elided*/ any;
|
|
152
736
|
isAfter(): {
|
|
153
737
|
days: (days: number) => {
|
|
154
738
|
inPast: () => JSONSchema;
|
|
@@ -237,8 +821,6 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
237
821
|
*/
|
|
238
822
|
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
239
823
|
};
|
|
240
|
-
asDob(): any;
|
|
241
|
-
asAge(): any;
|
|
242
824
|
isAfter(): {
|
|
243
825
|
days: (days: number) => {
|
|
244
826
|
inPast: () => JSONSchema;
|
|
@@ -339,10 +921,204 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
339
921
|
* @private Internal property used for field reference tracking.
|
|
340
922
|
*/
|
|
341
923
|
$$field: string;
|
|
342
|
-
get(fieldPath: string): any;
|
|
343
|
-
getByPath(fieldPath: string[]): any;
|
|
344
|
-
asDob():
|
|
345
|
-
|
|
924
|
+
get(fieldPath: string): /*elided*/ any;
|
|
925
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
926
|
+
asDob(): {
|
|
927
|
+
$$subfield: string[];
|
|
928
|
+
/**
|
|
929
|
+
* @private Internal property used for field reference tracking.
|
|
930
|
+
*/
|
|
931
|
+
$$field: string;
|
|
932
|
+
get(fieldPath: string): /*elided*/ any;
|
|
933
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
934
|
+
asDob(): /*elided*/ any;
|
|
935
|
+
asAge(): /*elided*/ any;
|
|
936
|
+
isAfter(): {
|
|
937
|
+
days: (days: number) => {
|
|
938
|
+
inPast: () => JSONSchema;
|
|
939
|
+
inFuture: () => JSONSchema;
|
|
940
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
941
|
+
fromNow: () => JSONSchema;
|
|
942
|
+
};
|
|
943
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
944
|
+
now: () => JSONSchema;
|
|
945
|
+
};
|
|
946
|
+
isBefore(): {
|
|
947
|
+
days: (days: number) => {
|
|
948
|
+
inPast: () => JSONSchema;
|
|
949
|
+
inFuture: () => JSONSchema;
|
|
950
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
951
|
+
fromNow: () => JSONSchema;
|
|
952
|
+
};
|
|
953
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
954
|
+
now: () => JSONSchema;
|
|
955
|
+
};
|
|
956
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
957
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
958
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
959
|
+
/**
|
|
960
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
961
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
962
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
963
|
+
*
|
|
964
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
965
|
+
*
|
|
966
|
+
*/
|
|
967
|
+
isFalsy(): JSONSchema;
|
|
968
|
+
isUndefined(): JSONSchema;
|
|
969
|
+
inArray(values: string[]): JSONSchema;
|
|
970
|
+
isValidEnglishName(): JSONSchema;
|
|
971
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
972
|
+
/**
|
|
973
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
974
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
975
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
976
|
+
*/
|
|
977
|
+
matches(pattern: string): JSONSchema;
|
|
978
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
979
|
+
getId: () => {
|
|
980
|
+
fieldId: string;
|
|
981
|
+
};
|
|
982
|
+
/**
|
|
983
|
+
* @deprecated
|
|
984
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
985
|
+
* with 'and' combinator e.g.
|
|
986
|
+
* and(
|
|
987
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
988
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
989
|
+
* )
|
|
990
|
+
*/
|
|
991
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
992
|
+
/**
|
|
993
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
994
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
995
|
+
* available inside the function body — all logic must be self-contained.
|
|
996
|
+
*
|
|
997
|
+
* @example
|
|
998
|
+
* field('nid').customClientValidator((value) => {
|
|
999
|
+
* // LUHN check — all logic must be inline
|
|
1000
|
+
* const digits = String(value).split('').map(Number)
|
|
1001
|
+
* // ...
|
|
1002
|
+
* return isValid
|
|
1003
|
+
* })
|
|
1004
|
+
*/
|
|
1005
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1006
|
+
/**
|
|
1007
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1008
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1009
|
+
* The function receives the referenced field's value as the first argument and
|
|
1010
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1011
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1012
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1013
|
+
*
|
|
1014
|
+
* For computing a default value without referencing a specific field, use
|
|
1015
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1016
|
+
*
|
|
1017
|
+
* @example
|
|
1018
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1019
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1020
|
+
* )
|
|
1021
|
+
*/
|
|
1022
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1023
|
+
};
|
|
1024
|
+
asAge(): {
|
|
1025
|
+
$$subfield: string[];
|
|
1026
|
+
/**
|
|
1027
|
+
* @private Internal property used for field reference tracking.
|
|
1028
|
+
*/
|
|
1029
|
+
$$field: string;
|
|
1030
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1031
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1032
|
+
asDob(): /*elided*/ any;
|
|
1033
|
+
asAge(): /*elided*/ any;
|
|
1034
|
+
isAfter(): {
|
|
1035
|
+
days: (days: number) => {
|
|
1036
|
+
inPast: () => JSONSchema;
|
|
1037
|
+
inFuture: () => JSONSchema;
|
|
1038
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1039
|
+
fromNow: () => JSONSchema;
|
|
1040
|
+
};
|
|
1041
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1042
|
+
now: () => JSONSchema;
|
|
1043
|
+
};
|
|
1044
|
+
isBefore(): {
|
|
1045
|
+
days: (days: number) => {
|
|
1046
|
+
inPast: () => JSONSchema;
|
|
1047
|
+
inFuture: () => JSONSchema;
|
|
1048
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1049
|
+
fromNow: () => JSONSchema;
|
|
1050
|
+
};
|
|
1051
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1052
|
+
now: () => JSONSchema;
|
|
1053
|
+
};
|
|
1054
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1055
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1056
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1057
|
+
/**
|
|
1058
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1059
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1060
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1061
|
+
*
|
|
1062
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1063
|
+
*
|
|
1064
|
+
*/
|
|
1065
|
+
isFalsy(): JSONSchema;
|
|
1066
|
+
isUndefined(): JSONSchema;
|
|
1067
|
+
inArray(values: string[]): JSONSchema;
|
|
1068
|
+
isValidEnglishName(): JSONSchema;
|
|
1069
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1070
|
+
/**
|
|
1071
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1072
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1073
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1074
|
+
*/
|
|
1075
|
+
matches(pattern: string): JSONSchema;
|
|
1076
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1077
|
+
getId: () => {
|
|
1078
|
+
fieldId: string;
|
|
1079
|
+
};
|
|
1080
|
+
/**
|
|
1081
|
+
* @deprecated
|
|
1082
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1083
|
+
* with 'and' combinator e.g.
|
|
1084
|
+
* and(
|
|
1085
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1086
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1087
|
+
* )
|
|
1088
|
+
*/
|
|
1089
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1090
|
+
/**
|
|
1091
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1092
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1093
|
+
* available inside the function body — all logic must be self-contained.
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* field('nid').customClientValidator((value) => {
|
|
1097
|
+
* // LUHN check — all logic must be inline
|
|
1098
|
+
* const digits = String(value).split('').map(Number)
|
|
1099
|
+
* // ...
|
|
1100
|
+
* return isValid
|
|
1101
|
+
* })
|
|
1102
|
+
*/
|
|
1103
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1104
|
+
/**
|
|
1105
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1106
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1107
|
+
* The function receives the referenced field's value as the first argument and
|
|
1108
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1109
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1110
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1111
|
+
*
|
|
1112
|
+
* For computing a default value without referencing a specific field, use
|
|
1113
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1114
|
+
*
|
|
1115
|
+
* @example
|
|
1116
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1117
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1118
|
+
* )
|
|
1119
|
+
*/
|
|
1120
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1121
|
+
};
|
|
346
1122
|
isAfter(): {
|
|
347
1123
|
days: (days: number) => {
|
|
348
1124
|
inPast: () => JSONSchema;
|
|
@@ -431,17 +1207,114 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
431
1207
|
*/
|
|
432
1208
|
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
433
1209
|
};
|
|
434
|
-
getByPath(fieldPath: string[]): any;
|
|
1210
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
435
1211
|
asDob(): {
|
|
436
1212
|
$$subfield: string[];
|
|
437
1213
|
/**
|
|
438
1214
|
* @private Internal property used for field reference tracking.
|
|
439
1215
|
*/
|
|
440
1216
|
$$field: string;
|
|
441
|
-
get(fieldPath: string):
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
1217
|
+
get(fieldPath: string): {
|
|
1218
|
+
$$subfield: string[];
|
|
1219
|
+
/**
|
|
1220
|
+
* @private Internal property used for field reference tracking.
|
|
1221
|
+
*/
|
|
1222
|
+
$$field: string;
|
|
1223
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1224
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1225
|
+
asDob(): /*elided*/ any;
|
|
1226
|
+
asAge(): /*elided*/ any;
|
|
1227
|
+
isAfter(): {
|
|
1228
|
+
days: (days: number) => {
|
|
1229
|
+
inPast: () => JSONSchema;
|
|
1230
|
+
inFuture: () => JSONSchema;
|
|
1231
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1232
|
+
fromNow: () => JSONSchema;
|
|
1233
|
+
};
|
|
1234
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1235
|
+
now: () => JSONSchema;
|
|
1236
|
+
};
|
|
1237
|
+
isBefore(): {
|
|
1238
|
+
days: (days: number) => {
|
|
1239
|
+
inPast: () => JSONSchema;
|
|
1240
|
+
inFuture: () => JSONSchema;
|
|
1241
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1242
|
+
fromNow: () => JSONSchema;
|
|
1243
|
+
};
|
|
1244
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1245
|
+
now: () => JSONSchema;
|
|
1246
|
+
};
|
|
1247
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1248
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1249
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1250
|
+
/**
|
|
1251
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1252
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1253
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1254
|
+
*
|
|
1255
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1256
|
+
*
|
|
1257
|
+
*/
|
|
1258
|
+
isFalsy(): JSONSchema;
|
|
1259
|
+
isUndefined(): JSONSchema;
|
|
1260
|
+
inArray(values: string[]): JSONSchema;
|
|
1261
|
+
isValidEnglishName(): JSONSchema;
|
|
1262
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1263
|
+
/**
|
|
1264
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1265
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1266
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1267
|
+
*/
|
|
1268
|
+
matches(pattern: string): JSONSchema;
|
|
1269
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1270
|
+
getId: () => {
|
|
1271
|
+
fieldId: string;
|
|
1272
|
+
};
|
|
1273
|
+
/**
|
|
1274
|
+
* @deprecated
|
|
1275
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1276
|
+
* with 'and' combinator e.g.
|
|
1277
|
+
* and(
|
|
1278
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1279
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1280
|
+
* )
|
|
1281
|
+
*/
|
|
1282
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1283
|
+
/**
|
|
1284
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1285
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1286
|
+
* available inside the function body — all logic must be self-contained.
|
|
1287
|
+
*
|
|
1288
|
+
* @example
|
|
1289
|
+
* field('nid').customClientValidator((value) => {
|
|
1290
|
+
* // LUHN check — all logic must be inline
|
|
1291
|
+
* const digits = String(value).split('').map(Number)
|
|
1292
|
+
* // ...
|
|
1293
|
+
* return isValid
|
|
1294
|
+
* })
|
|
1295
|
+
*/
|
|
1296
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1297
|
+
/**
|
|
1298
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1299
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1300
|
+
* The function receives the referenced field's value as the first argument and
|
|
1301
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1302
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1303
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1304
|
+
*
|
|
1305
|
+
* For computing a default value without referencing a specific field, use
|
|
1306
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1307
|
+
*
|
|
1308
|
+
* @example
|
|
1309
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1310
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1311
|
+
* )
|
|
1312
|
+
*/
|
|
1313
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1314
|
+
};
|
|
1315
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1316
|
+
asDob(): /*elided*/ any;
|
|
1317
|
+
asAge(): /*elided*/ any;
|
|
445
1318
|
isAfter(): {
|
|
446
1319
|
days: (days: number) => {
|
|
447
1320
|
inPast: () => JSONSchema;
|
|
@@ -536,10 +1409,107 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
536
1409
|
* @private Internal property used for field reference tracking.
|
|
537
1410
|
*/
|
|
538
1411
|
$$field: string;
|
|
539
|
-
get(fieldPath: string):
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
1412
|
+
get(fieldPath: string): {
|
|
1413
|
+
$$subfield: string[];
|
|
1414
|
+
/**
|
|
1415
|
+
* @private Internal property used for field reference tracking.
|
|
1416
|
+
*/
|
|
1417
|
+
$$field: string;
|
|
1418
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1419
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1420
|
+
asDob(): /*elided*/ any;
|
|
1421
|
+
asAge(): /*elided*/ any;
|
|
1422
|
+
isAfter(): {
|
|
1423
|
+
days: (days: number) => {
|
|
1424
|
+
inPast: () => JSONSchema;
|
|
1425
|
+
inFuture: () => JSONSchema;
|
|
1426
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1427
|
+
fromNow: () => JSONSchema;
|
|
1428
|
+
};
|
|
1429
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1430
|
+
now: () => JSONSchema;
|
|
1431
|
+
};
|
|
1432
|
+
isBefore(): {
|
|
1433
|
+
days: (days: number) => {
|
|
1434
|
+
inPast: () => JSONSchema;
|
|
1435
|
+
inFuture: () => JSONSchema;
|
|
1436
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1437
|
+
fromNow: () => JSONSchema;
|
|
1438
|
+
};
|
|
1439
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1440
|
+
now: () => JSONSchema;
|
|
1441
|
+
};
|
|
1442
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1443
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1444
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1445
|
+
/**
|
|
1446
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1447
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1448
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1449
|
+
*
|
|
1450
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1451
|
+
*
|
|
1452
|
+
*/
|
|
1453
|
+
isFalsy(): JSONSchema;
|
|
1454
|
+
isUndefined(): JSONSchema;
|
|
1455
|
+
inArray(values: string[]): JSONSchema;
|
|
1456
|
+
isValidEnglishName(): JSONSchema;
|
|
1457
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1458
|
+
/**
|
|
1459
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1460
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1461
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1462
|
+
*/
|
|
1463
|
+
matches(pattern: string): JSONSchema;
|
|
1464
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1465
|
+
getId: () => {
|
|
1466
|
+
fieldId: string;
|
|
1467
|
+
};
|
|
1468
|
+
/**
|
|
1469
|
+
* @deprecated
|
|
1470
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1471
|
+
* with 'and' combinator e.g.
|
|
1472
|
+
* and(
|
|
1473
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1474
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1475
|
+
* )
|
|
1476
|
+
*/
|
|
1477
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1478
|
+
/**
|
|
1479
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1480
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1481
|
+
* available inside the function body — all logic must be self-contained.
|
|
1482
|
+
*
|
|
1483
|
+
* @example
|
|
1484
|
+
* field('nid').customClientValidator((value) => {
|
|
1485
|
+
* // LUHN check — all logic must be inline
|
|
1486
|
+
* const digits = String(value).split('').map(Number)
|
|
1487
|
+
* // ...
|
|
1488
|
+
* return isValid
|
|
1489
|
+
* })
|
|
1490
|
+
*/
|
|
1491
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1492
|
+
/**
|
|
1493
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1494
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1495
|
+
* The function receives the referenced field's value as the first argument and
|
|
1496
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1497
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1498
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1499
|
+
*
|
|
1500
|
+
* For computing a default value without referencing a specific field, use
|
|
1501
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1502
|
+
*
|
|
1503
|
+
* @example
|
|
1504
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1505
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1506
|
+
* )
|
|
1507
|
+
*/
|
|
1508
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1509
|
+
};
|
|
1510
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1511
|
+
asDob(): /*elided*/ any;
|
|
1512
|
+
asAge(): /*elided*/ any;
|
|
543
1513
|
isAfter(): {
|
|
544
1514
|
days: (days: number) => {
|
|
545
1515
|
inPast: () => JSONSchema;
|
|
@@ -722,17 +1692,308 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
722
1692
|
* @private Internal property used for field reference tracking.
|
|
723
1693
|
*/
|
|
724
1694
|
$$field: string;
|
|
725
|
-
get(fieldPath: string):
|
|
1695
|
+
get(fieldPath: string): {
|
|
1696
|
+
$$subfield: string[];
|
|
1697
|
+
/**
|
|
1698
|
+
* @private Internal property used for field reference tracking.
|
|
1699
|
+
*/
|
|
1700
|
+
$$field: string;
|
|
1701
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1702
|
+
getByPath(fieldPath: string[]): {
|
|
1703
|
+
$$subfield: string[];
|
|
1704
|
+
/**
|
|
1705
|
+
* @private Internal property used for field reference tracking.
|
|
1706
|
+
*/
|
|
1707
|
+
$$field: string;
|
|
1708
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1709
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1710
|
+
asDob(): /*elided*/ any;
|
|
1711
|
+
asAge(): /*elided*/ any;
|
|
1712
|
+
isAfter(): {
|
|
1713
|
+
days: (days: number) => {
|
|
1714
|
+
inPast: () => JSONSchema;
|
|
1715
|
+
inFuture: () => JSONSchema;
|
|
1716
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1717
|
+
fromNow: () => JSONSchema;
|
|
1718
|
+
};
|
|
1719
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1720
|
+
now: () => JSONSchema;
|
|
1721
|
+
};
|
|
1722
|
+
isBefore(): {
|
|
1723
|
+
days: (days: number) => {
|
|
1724
|
+
inPast: () => JSONSchema;
|
|
1725
|
+
inFuture: () => JSONSchema;
|
|
1726
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1727
|
+
fromNow: () => JSONSchema;
|
|
1728
|
+
};
|
|
1729
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1730
|
+
now: () => JSONSchema;
|
|
1731
|
+
};
|
|
1732
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1733
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1734
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1735
|
+
/**
|
|
1736
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1737
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1738
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1739
|
+
*
|
|
1740
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1741
|
+
*
|
|
1742
|
+
*/
|
|
1743
|
+
isFalsy(): JSONSchema;
|
|
1744
|
+
isUndefined(): JSONSchema;
|
|
1745
|
+
inArray(values: string[]): JSONSchema;
|
|
1746
|
+
isValidEnglishName(): JSONSchema;
|
|
1747
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1748
|
+
/**
|
|
1749
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1750
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1751
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1752
|
+
*/
|
|
1753
|
+
matches(pattern: string): JSONSchema;
|
|
1754
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1755
|
+
getId: () => {
|
|
1756
|
+
fieldId: string;
|
|
1757
|
+
};
|
|
1758
|
+
/**
|
|
1759
|
+
* @deprecated
|
|
1760
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1761
|
+
* with 'and' combinator e.g.
|
|
1762
|
+
* and(
|
|
1763
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1764
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1765
|
+
* )
|
|
1766
|
+
*/
|
|
1767
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1768
|
+
/**
|
|
1769
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1770
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1771
|
+
* available inside the function body — all logic must be self-contained.
|
|
1772
|
+
*
|
|
1773
|
+
* @example
|
|
1774
|
+
* field('nid').customClientValidator((value) => {
|
|
1775
|
+
* // LUHN check — all logic must be inline
|
|
1776
|
+
* const digits = String(value).split('').map(Number)
|
|
1777
|
+
* // ...
|
|
1778
|
+
* return isValid
|
|
1779
|
+
* })
|
|
1780
|
+
*/
|
|
1781
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1782
|
+
/**
|
|
1783
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1784
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1785
|
+
* The function receives the referenced field's value as the first argument and
|
|
1786
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1787
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1788
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1789
|
+
*
|
|
1790
|
+
* For computing a default value without referencing a specific field, use
|
|
1791
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1792
|
+
*
|
|
1793
|
+
* @example
|
|
1794
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1795
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1796
|
+
* )
|
|
1797
|
+
*/
|
|
1798
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1799
|
+
};
|
|
1800
|
+
asDob(): /*elided*/ any;
|
|
1801
|
+
asAge(): /*elided*/ any;
|
|
1802
|
+
isAfter(): {
|
|
1803
|
+
days: (days: number) => {
|
|
1804
|
+
inPast: () => JSONSchema;
|
|
1805
|
+
inFuture: () => JSONSchema;
|
|
1806
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1807
|
+
fromNow: () => JSONSchema;
|
|
1808
|
+
};
|
|
1809
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1810
|
+
now: () => JSONSchema;
|
|
1811
|
+
};
|
|
1812
|
+
isBefore(): {
|
|
1813
|
+
days: (days: number) => {
|
|
1814
|
+
inPast: () => JSONSchema;
|
|
1815
|
+
inFuture: () => JSONSchema;
|
|
1816
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1817
|
+
fromNow: () => JSONSchema;
|
|
1818
|
+
};
|
|
1819
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1820
|
+
now: () => JSONSchema;
|
|
1821
|
+
};
|
|
1822
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1823
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1824
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1825
|
+
/**
|
|
1826
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1827
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1828
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1829
|
+
*
|
|
1830
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1831
|
+
*
|
|
1832
|
+
*/
|
|
1833
|
+
isFalsy(): JSONSchema;
|
|
1834
|
+
isUndefined(): JSONSchema;
|
|
1835
|
+
inArray(values: string[]): JSONSchema;
|
|
1836
|
+
isValidEnglishName(): JSONSchema;
|
|
1837
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1838
|
+
/**
|
|
1839
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1840
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1841
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1842
|
+
*/
|
|
1843
|
+
matches(pattern: string): JSONSchema;
|
|
1844
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1845
|
+
getId: () => {
|
|
1846
|
+
fieldId: string;
|
|
1847
|
+
};
|
|
1848
|
+
/**
|
|
1849
|
+
* @deprecated
|
|
1850
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1851
|
+
* with 'and' combinator e.g.
|
|
1852
|
+
* and(
|
|
1853
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1854
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1855
|
+
* )
|
|
1856
|
+
*/
|
|
1857
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1858
|
+
/**
|
|
1859
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1860
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1861
|
+
* available inside the function body — all logic must be self-contained.
|
|
1862
|
+
*
|
|
1863
|
+
* @example
|
|
1864
|
+
* field('nid').customClientValidator((value) => {
|
|
1865
|
+
* // LUHN check — all logic must be inline
|
|
1866
|
+
* const digits = String(value).split('').map(Number)
|
|
1867
|
+
* // ...
|
|
1868
|
+
* return isValid
|
|
1869
|
+
* })
|
|
1870
|
+
*/
|
|
1871
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1872
|
+
/**
|
|
1873
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1874
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1875
|
+
* The function receives the referenced field's value as the first argument and
|
|
1876
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1877
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1878
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1879
|
+
*
|
|
1880
|
+
* For computing a default value without referencing a specific field, use
|
|
1881
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1882
|
+
*
|
|
1883
|
+
* @example
|
|
1884
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1885
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1886
|
+
* )
|
|
1887
|
+
*/
|
|
1888
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1889
|
+
};
|
|
726
1890
|
getByPath(fieldPath: string[]): {
|
|
727
1891
|
$$subfield: string[];
|
|
728
1892
|
/**
|
|
729
1893
|
* @private Internal property used for field reference tracking.
|
|
730
1894
|
*/
|
|
731
1895
|
$$field: string;
|
|
732
|
-
get(fieldPath: string):
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
1896
|
+
get(fieldPath: string): {
|
|
1897
|
+
$$subfield: string[];
|
|
1898
|
+
/**
|
|
1899
|
+
* @private Internal property used for field reference tracking.
|
|
1900
|
+
*/
|
|
1901
|
+
$$field: string;
|
|
1902
|
+
get(fieldPath: string): /*elided*/ any;
|
|
1903
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1904
|
+
asDob(): /*elided*/ any;
|
|
1905
|
+
asAge(): /*elided*/ any;
|
|
1906
|
+
isAfter(): {
|
|
1907
|
+
days: (days: number) => {
|
|
1908
|
+
inPast: () => JSONSchema;
|
|
1909
|
+
inFuture: () => JSONSchema;
|
|
1910
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1911
|
+
fromNow: () => JSONSchema;
|
|
1912
|
+
};
|
|
1913
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
1914
|
+
now: () => JSONSchema;
|
|
1915
|
+
};
|
|
1916
|
+
isBefore(): {
|
|
1917
|
+
days: (days: number) => {
|
|
1918
|
+
inPast: () => JSONSchema;
|
|
1919
|
+
inFuture: () => JSONSchema;
|
|
1920
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1921
|
+
fromNow: () => JSONSchema;
|
|
1922
|
+
};
|
|
1923
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
1924
|
+
now: () => JSONSchema;
|
|
1925
|
+
};
|
|
1926
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
1927
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
1928
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
1929
|
+
/**
|
|
1930
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
1931
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
1932
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
1933
|
+
*
|
|
1934
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
1935
|
+
*
|
|
1936
|
+
*/
|
|
1937
|
+
isFalsy(): JSONSchema;
|
|
1938
|
+
isUndefined(): JSONSchema;
|
|
1939
|
+
inArray(values: string[]): JSONSchema;
|
|
1940
|
+
isValidEnglishName(): JSONSchema;
|
|
1941
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
1942
|
+
/**
|
|
1943
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
1944
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
1945
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
1946
|
+
*/
|
|
1947
|
+
matches(pattern: string): JSONSchema;
|
|
1948
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
1949
|
+
getId: () => {
|
|
1950
|
+
fieldId: string;
|
|
1951
|
+
};
|
|
1952
|
+
/**
|
|
1953
|
+
* @deprecated
|
|
1954
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
1955
|
+
* with 'and' combinator e.g.
|
|
1956
|
+
* and(
|
|
1957
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
1958
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
1959
|
+
* )
|
|
1960
|
+
*/
|
|
1961
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
1962
|
+
/**
|
|
1963
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1964
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1965
|
+
* available inside the function body — all logic must be self-contained.
|
|
1966
|
+
*
|
|
1967
|
+
* @example
|
|
1968
|
+
* field('nid').customClientValidator((value) => {
|
|
1969
|
+
* // LUHN check — all logic must be inline
|
|
1970
|
+
* const digits = String(value).split('').map(Number)
|
|
1971
|
+
* // ...
|
|
1972
|
+
* return isValid
|
|
1973
|
+
* })
|
|
1974
|
+
*/
|
|
1975
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1976
|
+
/**
|
|
1977
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1978
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1979
|
+
* The function receives the referenced field's value as the first argument and
|
|
1980
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1981
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1982
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1983
|
+
*
|
|
1984
|
+
* For computing a default value without referencing a specific field, use
|
|
1985
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1986
|
+
*
|
|
1987
|
+
* @example
|
|
1988
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1989
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1990
|
+
* )
|
|
1991
|
+
*/
|
|
1992
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1993
|
+
};
|
|
1994
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
1995
|
+
asDob(): /*elided*/ any;
|
|
1996
|
+
asAge(): /*elided*/ any;
|
|
736
1997
|
isAfter(): {
|
|
737
1998
|
days: (days: number) => {
|
|
738
1999
|
inPast: () => JSONSchema;
|
|
@@ -821,8 +2082,8 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
821
2082
|
*/
|
|
822
2083
|
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
823
2084
|
};
|
|
824
|
-
asDob(): any;
|
|
825
|
-
asAge(): any;
|
|
2085
|
+
asDob(): /*elided*/ any;
|
|
2086
|
+
asAge(): /*elided*/ any;
|
|
826
2087
|
isAfter(): {
|
|
827
2088
|
days: (days: number) => {
|
|
828
2089
|
inPast: () => JSONSchema;
|
|
@@ -917,17 +2178,308 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
917
2178
|
* @private Internal property used for field reference tracking.
|
|
918
2179
|
*/
|
|
919
2180
|
$$field: string;
|
|
920
|
-
get(fieldPath: string):
|
|
2181
|
+
get(fieldPath: string): {
|
|
2182
|
+
$$subfield: string[];
|
|
2183
|
+
/**
|
|
2184
|
+
* @private Internal property used for field reference tracking.
|
|
2185
|
+
*/
|
|
2186
|
+
$$field: string;
|
|
2187
|
+
get(fieldPath: string): /*elided*/ any;
|
|
2188
|
+
getByPath(fieldPath: string[]): {
|
|
2189
|
+
$$subfield: string[];
|
|
2190
|
+
/**
|
|
2191
|
+
* @private Internal property used for field reference tracking.
|
|
2192
|
+
*/
|
|
2193
|
+
$$field: string;
|
|
2194
|
+
get(fieldPath: string): /*elided*/ any;
|
|
2195
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
2196
|
+
asDob(): /*elided*/ any;
|
|
2197
|
+
asAge(): /*elided*/ any;
|
|
2198
|
+
isAfter(): {
|
|
2199
|
+
days: (days: number) => {
|
|
2200
|
+
inPast: () => JSONSchema;
|
|
2201
|
+
inFuture: () => JSONSchema;
|
|
2202
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2203
|
+
fromNow: () => JSONSchema;
|
|
2204
|
+
};
|
|
2205
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
2206
|
+
now: () => JSONSchema;
|
|
2207
|
+
};
|
|
2208
|
+
isBefore(): {
|
|
2209
|
+
days: (days: number) => {
|
|
2210
|
+
inPast: () => JSONSchema;
|
|
2211
|
+
inFuture: () => JSONSchema;
|
|
2212
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2213
|
+
fromNow: () => JSONSchema;
|
|
2214
|
+
};
|
|
2215
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2216
|
+
now: () => JSONSchema;
|
|
2217
|
+
};
|
|
2218
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
2219
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
2220
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
2221
|
+
/**
|
|
2222
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
2223
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
2224
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
2225
|
+
*
|
|
2226
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
2227
|
+
*
|
|
2228
|
+
*/
|
|
2229
|
+
isFalsy(): JSONSchema;
|
|
2230
|
+
isUndefined(): JSONSchema;
|
|
2231
|
+
inArray(values: string[]): JSONSchema;
|
|
2232
|
+
isValidEnglishName(): JSONSchema;
|
|
2233
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
2234
|
+
/**
|
|
2235
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
2236
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
2237
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
2238
|
+
*/
|
|
2239
|
+
matches(pattern: string): JSONSchema;
|
|
2240
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
2241
|
+
getId: () => {
|
|
2242
|
+
fieldId: string;
|
|
2243
|
+
};
|
|
2244
|
+
/**
|
|
2245
|
+
* @deprecated
|
|
2246
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
2247
|
+
* with 'and' combinator e.g.
|
|
2248
|
+
* and(
|
|
2249
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
2250
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
2251
|
+
* )
|
|
2252
|
+
*/
|
|
2253
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
2254
|
+
/**
|
|
2255
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2256
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2257
|
+
* available inside the function body — all logic must be self-contained.
|
|
2258
|
+
*
|
|
2259
|
+
* @example
|
|
2260
|
+
* field('nid').customClientValidator((value) => {
|
|
2261
|
+
* // LUHN check — all logic must be inline
|
|
2262
|
+
* const digits = String(value).split('').map(Number)
|
|
2263
|
+
* // ...
|
|
2264
|
+
* return isValid
|
|
2265
|
+
* })
|
|
2266
|
+
*/
|
|
2267
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2268
|
+
/**
|
|
2269
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2270
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2271
|
+
* The function receives the referenced field's value as the first argument and
|
|
2272
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2273
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2274
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2275
|
+
*
|
|
2276
|
+
* For computing a default value without referencing a specific field, use
|
|
2277
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2278
|
+
*
|
|
2279
|
+
* @example
|
|
2280
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2281
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2282
|
+
* )
|
|
2283
|
+
*/
|
|
2284
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
2285
|
+
};
|
|
2286
|
+
asDob(): /*elided*/ any;
|
|
2287
|
+
asAge(): /*elided*/ any;
|
|
2288
|
+
isAfter(): {
|
|
2289
|
+
days: (days: number) => {
|
|
2290
|
+
inPast: () => JSONSchema;
|
|
2291
|
+
inFuture: () => JSONSchema;
|
|
2292
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2293
|
+
fromNow: () => JSONSchema;
|
|
2294
|
+
};
|
|
2295
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
2296
|
+
now: () => JSONSchema;
|
|
2297
|
+
};
|
|
2298
|
+
isBefore(): {
|
|
2299
|
+
days: (days: number) => {
|
|
2300
|
+
inPast: () => JSONSchema;
|
|
2301
|
+
inFuture: () => JSONSchema;
|
|
2302
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2303
|
+
fromNow: () => JSONSchema;
|
|
2304
|
+
};
|
|
2305
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2306
|
+
now: () => JSONSchema;
|
|
2307
|
+
};
|
|
2308
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
2309
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
2310
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
2311
|
+
/**
|
|
2312
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
2313
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
2314
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
2315
|
+
*
|
|
2316
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
2317
|
+
*
|
|
2318
|
+
*/
|
|
2319
|
+
isFalsy(): JSONSchema;
|
|
2320
|
+
isUndefined(): JSONSchema;
|
|
2321
|
+
inArray(values: string[]): JSONSchema;
|
|
2322
|
+
isValidEnglishName(): JSONSchema;
|
|
2323
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
2324
|
+
/**
|
|
2325
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
2326
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
2327
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
2328
|
+
*/
|
|
2329
|
+
matches(pattern: string): JSONSchema;
|
|
2330
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
2331
|
+
getId: () => {
|
|
2332
|
+
fieldId: string;
|
|
2333
|
+
};
|
|
2334
|
+
/**
|
|
2335
|
+
* @deprecated
|
|
2336
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
2337
|
+
* with 'and' combinator e.g.
|
|
2338
|
+
* and(
|
|
2339
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
2340
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
2341
|
+
* )
|
|
2342
|
+
*/
|
|
2343
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
2344
|
+
/**
|
|
2345
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2346
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2347
|
+
* available inside the function body — all logic must be self-contained.
|
|
2348
|
+
*
|
|
2349
|
+
* @example
|
|
2350
|
+
* field('nid').customClientValidator((value) => {
|
|
2351
|
+
* // LUHN check — all logic must be inline
|
|
2352
|
+
* const digits = String(value).split('').map(Number)
|
|
2353
|
+
* // ...
|
|
2354
|
+
* return isValid
|
|
2355
|
+
* })
|
|
2356
|
+
*/
|
|
2357
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2358
|
+
/**
|
|
2359
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2360
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2361
|
+
* The function receives the referenced field's value as the first argument and
|
|
2362
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2363
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2364
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2365
|
+
*
|
|
2366
|
+
* For computing a default value without referencing a specific field, use
|
|
2367
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2368
|
+
*
|
|
2369
|
+
* @example
|
|
2370
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2371
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2372
|
+
* )
|
|
2373
|
+
*/
|
|
2374
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
2375
|
+
};
|
|
921
2376
|
getByPath(fieldPath: string[]): {
|
|
922
2377
|
$$subfield: string[];
|
|
923
2378
|
/**
|
|
924
2379
|
* @private Internal property used for field reference tracking.
|
|
925
2380
|
*/
|
|
926
2381
|
$$field: string;
|
|
927
|
-
get(fieldPath: string):
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
2382
|
+
get(fieldPath: string): {
|
|
2383
|
+
$$subfield: string[];
|
|
2384
|
+
/**
|
|
2385
|
+
* @private Internal property used for field reference tracking.
|
|
2386
|
+
*/
|
|
2387
|
+
$$field: string;
|
|
2388
|
+
get(fieldPath: string): /*elided*/ any;
|
|
2389
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
2390
|
+
asDob(): /*elided*/ any;
|
|
2391
|
+
asAge(): /*elided*/ any;
|
|
2392
|
+
isAfter(): {
|
|
2393
|
+
days: (days: number) => {
|
|
2394
|
+
inPast: () => JSONSchema;
|
|
2395
|
+
inFuture: () => JSONSchema;
|
|
2396
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2397
|
+
fromNow: () => JSONSchema;
|
|
2398
|
+
};
|
|
2399
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
2400
|
+
now: () => JSONSchema;
|
|
2401
|
+
};
|
|
2402
|
+
isBefore(): {
|
|
2403
|
+
days: (days: number) => {
|
|
2404
|
+
inPast: () => JSONSchema;
|
|
2405
|
+
inFuture: () => JSONSchema;
|
|
2406
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2407
|
+
fromNow: () => JSONSchema;
|
|
2408
|
+
};
|
|
2409
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
2410
|
+
now: () => JSONSchema;
|
|
2411
|
+
};
|
|
2412
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
2413
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
2414
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
2415
|
+
/**
|
|
2416
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
2417
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
2418
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
2419
|
+
*
|
|
2420
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
2421
|
+
*
|
|
2422
|
+
*/
|
|
2423
|
+
isFalsy(): JSONSchema;
|
|
2424
|
+
isUndefined(): JSONSchema;
|
|
2425
|
+
inArray(values: string[]): JSONSchema;
|
|
2426
|
+
isValidEnglishName(): JSONSchema;
|
|
2427
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
2428
|
+
/**
|
|
2429
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
2430
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
2431
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
2432
|
+
*/
|
|
2433
|
+
matches(pattern: string): JSONSchema;
|
|
2434
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
2435
|
+
getId: () => {
|
|
2436
|
+
fieldId: string;
|
|
2437
|
+
};
|
|
2438
|
+
/**
|
|
2439
|
+
* @deprecated
|
|
2440
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
2441
|
+
* with 'and' combinator e.g.
|
|
2442
|
+
* and(
|
|
2443
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
2444
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
2445
|
+
* )
|
|
2446
|
+
*/
|
|
2447
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
2448
|
+
/**
|
|
2449
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2450
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2451
|
+
* available inside the function body — all logic must be self-contained.
|
|
2452
|
+
*
|
|
2453
|
+
* @example
|
|
2454
|
+
* field('nid').customClientValidator((value) => {
|
|
2455
|
+
* // LUHN check — all logic must be inline
|
|
2456
|
+
* const digits = String(value).split('').map(Number)
|
|
2457
|
+
* // ...
|
|
2458
|
+
* return isValid
|
|
2459
|
+
* })
|
|
2460
|
+
*/
|
|
2461
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2462
|
+
/**
|
|
2463
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2464
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2465
|
+
* The function receives the referenced field's value as the first argument and
|
|
2466
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2467
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2468
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2469
|
+
*
|
|
2470
|
+
* For computing a default value without referencing a specific field, use
|
|
2471
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2472
|
+
*
|
|
2473
|
+
* @example
|
|
2474
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2475
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2476
|
+
* )
|
|
2477
|
+
*/
|
|
2478
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
2479
|
+
};
|
|
2480
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
2481
|
+
asDob(): /*elided*/ any;
|
|
2482
|
+
asAge(): /*elided*/ any;
|
|
931
2483
|
isAfter(): {
|
|
932
2484
|
days: (days: number) => {
|
|
933
2485
|
inPast: () => JSONSchema;
|
|
@@ -1016,8 +2568,8 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
1016
2568
|
*/
|
|
1017
2569
|
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
1018
2570
|
};
|
|
1019
|
-
asDob(): any;
|
|
1020
|
-
asAge(): any;
|
|
2571
|
+
asDob(): /*elided*/ any;
|
|
2572
|
+
asAge(): /*elided*/ any;
|
|
1021
2573
|
isAfter(): {
|
|
1022
2574
|
days: (days: number) => {
|
|
1023
2575
|
inPast: () => JSONSchema;
|