@opencrvs/toolkit 2.0.0-rc.5b847e3 → 2.0.0-rc.5ba2797
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/README.md +15 -0
- package/build.sh +3 -2
- package/dist/application-config/index.js +70 -40
- package/dist/cli.js +3262 -50
- package/dist/commons/api/router.d.ts +212 -127
- package/dist/commons/application-config/index.d.ts +1 -0
- package/dist/commons/conditionals/conditionals.d.ts +1937 -41
- package/dist/commons/conditionals/validate.d.ts +51 -2
- package/dist/commons/events/ActionConfig.d.ts +28 -2
- package/dist/commons/events/ActionDocument.d.ts +6 -0
- package/dist/commons/events/ActionInput.d.ts +6 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
- package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
- package/dist/commons/events/EventConfig.d.ts +2 -0
- package/dist/commons/events/EventDocument.d.ts +3 -0
- package/dist/commons/events/EventIndex.d.ts +25 -0
- package/dist/commons/events/EventMetadata.d.ts +26 -0
- package/dist/commons/events/FieldConfig.d.ts +388 -50
- package/dist/commons/events/FieldType.d.ts +1 -0
- package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
- package/dist/commons/events/FieldValue.d.ts +6 -0
- package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
- package/dist/commons/events/field.d.ts +775 -35
- package/dist/commons/events/index.d.ts +1 -0
- package/dist/commons/events/locations.d.ts +1 -0
- package/dist/commons/events/state/flags.d.ts +14 -0
- package/dist/commons/events/state/index.d.ts +8 -0
- package/dist/commons/events/state/utils.d.ts +21 -287
- package/dist/commons/events/utils.d.ts +12 -1
- package/dist/conditionals/index.js +58 -6
- package/dist/environment/custom-types.d.ts +33 -0
- package/dist/environment/custom-types.d.ts.map +1 -0
- package/dist/environment/custom-types.js +12 -0
- package/dist/environment/derived-variables.d.ts +134 -0
- package/dist/environment/derived-variables.d.ts.map +1 -0
- package/dist/environment/derived-variables.js +169 -0
- package/dist/environment/editor-questions.d.ts +4 -0
- package/dist/environment/editor-questions.d.ts.map +1 -0
- package/dist/environment/editor-questions.js +67 -0
- package/dist/environment/git.d.ts +5 -0
- package/dist/environment/git.d.ts.map +1 -0
- package/dist/environment/git.js +38 -0
- package/dist/environment/github.d.ts +26 -0
- package/dist/environment/github.d.ts.map +1 -0
- package/dist/environment/github.js +247 -0
- package/dist/environment/index.d.ts +5 -0
- package/dist/environment/index.d.ts.map +1 -0
- package/dist/environment/index.js +71 -0
- package/dist/environment/logger.d.ts +6 -0
- package/dist/environment/logger.d.ts.map +1 -0
- package/dist/environment/logger.js +25 -0
- package/dist/environment/manage-users.d.ts +11 -0
- package/dist/environment/manage-users.d.ts.map +1 -0
- package/dist/environment/manage-users.js +507 -0
- package/dist/environment/questions-helper.d.ts +15 -0
- package/dist/environment/questions-helper.d.ts.map +1 -0
- package/dist/environment/questions-helper.js +70 -0
- package/dist/environment/questions.d.ts +199 -0
- package/dist/environment/questions.d.ts.map +1 -0
- package/dist/environment/questions.js +412 -0
- package/dist/environment/setup-environment.d.ts +2 -0
- package/dist/environment/setup-environment.d.ts.map +1 -0
- package/dist/environment/setup-environment.js +794 -0
- package/dist/environment/ssh-keygen.d.ts +5 -0
- package/dist/environment/ssh-keygen.d.ts.map +1 -0
- package/dist/environment/ssh-keygen.js +21 -0
- package/dist/environment/swarm-to-k8s.d.ts +2 -0
- package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
- package/dist/environment/swarm-to-k8s.js +183 -0
- package/dist/environment/templates.d.ts +27 -0
- package/dist/environment/templates.d.ts.map +1 -0
- package/dist/environment/templates.js +163 -0
- package/dist/environment/update-workflows.d.ts +2 -0
- package/dist/environment/update-workflows.d.ts.map +1 -0
- package/dist/environment/update-workflows.js +179 -0
- package/dist/environment/users.d.ts +2 -0
- package/dist/environment/users.d.ts.map +1 -0
- package/dist/environment/users.js +122 -0
- package/dist/environment/utils.d.ts +18 -0
- package/dist/environment/utils.d.ts.map +1 -0
- package/dist/environment/utils.js +110 -0
- package/dist/events/index.js +441 -147
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
- package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
- package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
- package/dist/migrations/v2.0/index.js +20 -9
- package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
- package/dist/notification/index.js +265 -45
- package/dist/scopes/index.d.ts +93 -7
- package/dist/scopes/index.js +19 -8
- package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
- package/dist/templates/charts-values/dependencies/values.yaml +83 -0
- package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
- package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
- package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
- package/dist/templates/charts-values/traefik/values.yaml +115 -0
- package/dist/templates/inventory/inventory.template.yml +100 -0
- package/dist/templates/inventory/production.example.yml +77 -0
- package/dist/templates/inventory/qa.example.yml +48 -0
- package/opencrvs-toolkit-2.0.0-rc.5ba2797.tgz +0 -0
- package/package.json +16 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.0-rc.5b847e3.tgz +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EventDocument } from '../events/EventDocument';
|
|
2
|
-
import { EventState } from '../events/ActionDocument';
|
|
2
|
+
import { ActionUpdate, EventState } from '../events/ActionDocument';
|
|
3
3
|
import { ITokenPayload as TokenPayload } from '../authentication';
|
|
4
4
|
import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema';
|
|
5
5
|
import { userSerializer } from '../events/serializers/user/serializer';
|
|
6
6
|
import { UUID } from '../uuid';
|
|
7
7
|
import { todayDateTimeValueSerializer } from '../events/serializers/date/serializer';
|
|
8
8
|
import { EventStatus } from '../events/EventMetadata';
|
|
9
|
-
import { FieldReference } from '../events/FieldConfig';
|
|
9
|
+
import { CodeToEvaluate, FieldReference } from '../events/FieldConfig';
|
|
10
|
+
import type { ClientFunctionContext } from './validate';
|
|
10
11
|
/** @knipignore */
|
|
11
12
|
export type JSONSchema = {
|
|
12
13
|
$id: string;
|
|
@@ -25,7 +26,7 @@ export type EventConditionalParameters = CommonConditionalParameters & {
|
|
|
25
26
|
$event: EventDocument;
|
|
26
27
|
};
|
|
27
28
|
export type FormConditionalParameters = CommonConditionalParameters & {
|
|
28
|
-
$form: EventState |
|
|
29
|
+
$form: EventState | ActionUpdate;
|
|
29
30
|
$leafAdminStructureLocationIds?: Array<{
|
|
30
31
|
id: UUID;
|
|
31
32
|
}>;
|
|
@@ -93,21 +94,23 @@ export declare const user: typeof userSerializer & {
|
|
|
93
94
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
94
95
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
95
96
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
96
|
-
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
97
|
+
$option: "role" | "event" | "placeOfEvent" | "notifiedIn" | "notifiedBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
97
98
|
};
|
|
98
99
|
};
|
|
99
100
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
100
101
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
101
|
-
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
102
|
+
$option: "role" | "event" | "placeOfEvent" | "notifiedIn" | "notifiedBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
102
103
|
}) => {
|
|
103
104
|
$jurisdiction: "administrativeArea" | "location" | "all" | {
|
|
104
105
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
105
|
-
$option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
106
|
+
$option: "role" | "event" | "placeOfEvent" | "notifiedIn" | "notifiedBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
106
107
|
};
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
110
|
export declare function isFieldReference(value: unknown): value is FieldReference;
|
|
110
|
-
export declare function isEventFieldReference(value: unknown): value is
|
|
111
|
+
export declare function isEventFieldReference(value: unknown): value is {
|
|
112
|
+
$$event: string;
|
|
113
|
+
};
|
|
111
114
|
/** Check if an event flag is present */
|
|
112
115
|
export declare function flag(flagvalue: string): JSONSchema;
|
|
113
116
|
/** Check if an event flag is present */
|
|
@@ -135,17 +138,406 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
135
138
|
* @private Internal property used for field reference tracking.
|
|
136
139
|
*/
|
|
137
140
|
$$field: string;
|
|
138
|
-
get(fieldPath: string): any;
|
|
141
|
+
get(fieldPath: string): /*elided*/ any;
|
|
139
142
|
getByPath(fieldPath: string[]): {
|
|
140
143
|
$$subfield: string[];
|
|
141
144
|
/**
|
|
142
145
|
* @private Internal property used for field reference tracking.
|
|
143
146
|
*/
|
|
144
147
|
$$field: string;
|
|
145
|
-
get(fieldPath: string): any;
|
|
146
|
-
getByPath(fieldPath: string[]): any;
|
|
147
|
-
asDob():
|
|
148
|
-
|
|
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;
|
|
149
541
|
isAfter(): {
|
|
150
542
|
days: (days: number) => {
|
|
151
543
|
inPast: () => JSONSchema;
|
|
@@ -202,9 +594,233 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
202
594
|
* )
|
|
203
595
|
*/
|
|
204
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;
|
|
736
|
+
isAfter(): {
|
|
737
|
+
days: (days: number) => {
|
|
738
|
+
inPast: () => JSONSchema;
|
|
739
|
+
inFuture: () => JSONSchema;
|
|
740
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
741
|
+
fromNow: () => JSONSchema;
|
|
742
|
+
};
|
|
743
|
+
date: (date: string | FieldReference) => JSONSchema;
|
|
744
|
+
now: () => JSONSchema;
|
|
745
|
+
};
|
|
746
|
+
isBefore(): {
|
|
747
|
+
days: (days: number) => {
|
|
748
|
+
inPast: () => JSONSchema;
|
|
749
|
+
inFuture: () => JSONSchema;
|
|
750
|
+
fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
751
|
+
fromNow: () => JSONSchema;
|
|
752
|
+
};
|
|
753
|
+
date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema;
|
|
754
|
+
now: () => JSONSchema;
|
|
755
|
+
};
|
|
756
|
+
isGreaterThan(value: number | FieldReference): JSONSchema;
|
|
757
|
+
isLessThan(value: number | FieldReference): JSONSchema;
|
|
758
|
+
isEqualTo(value: string | boolean | number | FieldReference): JSONSchema;
|
|
759
|
+
/**
|
|
760
|
+
* Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected.
|
|
761
|
+
* @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true))
|
|
762
|
+
* @returns whether the field is falsy (undefined, false, null, empty string)
|
|
763
|
+
*
|
|
764
|
+
* NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed.
|
|
765
|
+
*
|
|
766
|
+
*/
|
|
767
|
+
isFalsy(): JSONSchema;
|
|
768
|
+
isUndefined(): JSONSchema;
|
|
769
|
+
inArray(values: string[]): JSONSchema;
|
|
770
|
+
isValidEnglishName(): JSONSchema;
|
|
771
|
+
isValidAdministrativeLeafLevel(): JSONSchema;
|
|
772
|
+
/**
|
|
773
|
+
* Checks if the field value matches a given regular expression pattern.
|
|
774
|
+
* @param pattern - The regular expression pattern to match the field value against.
|
|
775
|
+
* @returns A JSONSchema conditional that validates the field value against the pattern.
|
|
776
|
+
*/
|
|
777
|
+
matches(pattern: string): JSONSchema;
|
|
778
|
+
isBetween(min: number, max: number): JSONSchema;
|
|
779
|
+
getId: () => {
|
|
780
|
+
fieldId: string;
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* @deprecated
|
|
784
|
+
* use field(fieldId).get(nestedProperty) instead
|
|
785
|
+
* with 'and' combinator e.g.
|
|
786
|
+
* and(
|
|
787
|
+
* field('child.name').get('firstname').isEqualTo('John'),
|
|
788
|
+
* field('child.name').get('surname').isEqualTo('Doe')
|
|
789
|
+
* )
|
|
790
|
+
*/
|
|
791
|
+
object: (options: Record<string, any>) => JSONSchema;
|
|
792
|
+
/**
|
|
793
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
794
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
795
|
+
* available inside the function body — all logic must be self-contained.
|
|
796
|
+
*
|
|
797
|
+
* @example
|
|
798
|
+
* field('nid').customClientValidator((value) => {
|
|
799
|
+
* // LUHN check — all logic must be inline
|
|
800
|
+
* const digits = String(value).split('').map(Number)
|
|
801
|
+
* // ...
|
|
802
|
+
* return isValid
|
|
803
|
+
* })
|
|
804
|
+
*/
|
|
805
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
806
|
+
/**
|
|
807
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
808
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
809
|
+
* The function receives the referenced field's value as the first argument and
|
|
810
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
811
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
812
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
813
|
+
*
|
|
814
|
+
* For computing a default value without referencing a specific field, use
|
|
815
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
816
|
+
*
|
|
817
|
+
* @example
|
|
818
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
819
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
820
|
+
* )
|
|
821
|
+
*/
|
|
822
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
205
823
|
};
|
|
206
|
-
asDob(): any;
|
|
207
|
-
asAge(): any;
|
|
208
824
|
isAfter(): {
|
|
209
825
|
days: (days: number) => {
|
|
210
826
|
inPast: () => JSONSchema;
|
|
@@ -261,6 +877,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
261
877
|
* )
|
|
262
878
|
*/
|
|
263
879
|
object: (options: Record<string, any>) => JSONSchema;
|
|
880
|
+
/**
|
|
881
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
882
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
883
|
+
* available inside the function body — all logic must be self-contained.
|
|
884
|
+
*
|
|
885
|
+
* @example
|
|
886
|
+
* field('nid').customClientValidator((value) => {
|
|
887
|
+
* // LUHN check — all logic must be inline
|
|
888
|
+
* const digits = String(value).split('').map(Number)
|
|
889
|
+
* // ...
|
|
890
|
+
* return isValid
|
|
891
|
+
* })
|
|
892
|
+
*/
|
|
893
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
894
|
+
/**
|
|
895
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
896
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
897
|
+
* The function receives the referenced field's value as the first argument and
|
|
898
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
899
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
900
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
901
|
+
*
|
|
902
|
+
* For computing a default value without referencing a specific field, use
|
|
903
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
907
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
908
|
+
* )
|
|
909
|
+
*/
|
|
910
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
264
911
|
};
|
|
265
912
|
getByPath(fieldPath: string[]): {
|
|
266
913
|
$$subfield: string[];
|
|
@@ -274,10 +921,204 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
274
921
|
* @private Internal property used for field reference tracking.
|
|
275
922
|
*/
|
|
276
923
|
$$field: string;
|
|
277
|
-
get(fieldPath: string): any;
|
|
278
|
-
getByPath(fieldPath: string[]): any;
|
|
279
|
-
asDob():
|
|
280
|
-
|
|
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
|
+
};
|
|
281
1122
|
isAfter(): {
|
|
282
1123
|
days: (days: number) => {
|
|
283
1124
|
inPast: () => JSONSchema;
|
|
@@ -334,18 +1175,146 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
334
1175
|
* )
|
|
335
1176
|
*/
|
|
336
1177
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1178
|
+
/**
|
|
1179
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1180
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1181
|
+
* available inside the function body — all logic must be self-contained.
|
|
1182
|
+
*
|
|
1183
|
+
* @example
|
|
1184
|
+
* field('nid').customClientValidator((value) => {
|
|
1185
|
+
* // LUHN check — all logic must be inline
|
|
1186
|
+
* const digits = String(value).split('').map(Number)
|
|
1187
|
+
* // ...
|
|
1188
|
+
* return isValid
|
|
1189
|
+
* })
|
|
1190
|
+
*/
|
|
1191
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1192
|
+
/**
|
|
1193
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1194
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1195
|
+
* The function receives the referenced field's value as the first argument and
|
|
1196
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1197
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1198
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1199
|
+
*
|
|
1200
|
+
* For computing a default value without referencing a specific field, use
|
|
1201
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1202
|
+
*
|
|
1203
|
+
* @example
|
|
1204
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1205
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1206
|
+
* )
|
|
1207
|
+
*/
|
|
1208
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
337
1209
|
};
|
|
338
|
-
getByPath(fieldPath: string[]): any;
|
|
1210
|
+
getByPath(fieldPath: string[]): /*elided*/ any;
|
|
339
1211
|
asDob(): {
|
|
340
1212
|
$$subfield: string[];
|
|
341
1213
|
/**
|
|
342
1214
|
* @private Internal property used for field reference tracking.
|
|
343
1215
|
*/
|
|
344
1216
|
$$field: string;
|
|
345
|
-
get(fieldPath: string):
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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;
|
|
349
1318
|
isAfter(): {
|
|
350
1319
|
days: (days: number) => {
|
|
351
1320
|
inPast: () => JSONSchema;
|
|
@@ -402,6 +1371,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
402
1371
|
* )
|
|
403
1372
|
*/
|
|
404
1373
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1374
|
+
/**
|
|
1375
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1376
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1377
|
+
* available inside the function body — all logic must be self-contained.
|
|
1378
|
+
*
|
|
1379
|
+
* @example
|
|
1380
|
+
* field('nid').customClientValidator((value) => {
|
|
1381
|
+
* // LUHN check — all logic must be inline
|
|
1382
|
+
* const digits = String(value).split('').map(Number)
|
|
1383
|
+
* // ...
|
|
1384
|
+
* return isValid
|
|
1385
|
+
* })
|
|
1386
|
+
*/
|
|
1387
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1388
|
+
/**
|
|
1389
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1390
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1391
|
+
* The function receives the referenced field's value as the first argument and
|
|
1392
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1393
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1394
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1395
|
+
*
|
|
1396
|
+
* For computing a default value without referencing a specific field, use
|
|
1397
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1398
|
+
*
|
|
1399
|
+
* @example
|
|
1400
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1401
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1402
|
+
* )
|
|
1403
|
+
*/
|
|
1404
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
405
1405
|
};
|
|
406
1406
|
asAge(): {
|
|
407
1407
|
$$subfield: string[];
|
|
@@ -409,10 +1409,107 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
409
1409
|
* @private Internal property used for field reference tracking.
|
|
410
1410
|
*/
|
|
411
1411
|
$$field: string;
|
|
412
|
-
get(fieldPath: string):
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
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;
|
|
416
1513
|
isAfter(): {
|
|
417
1514
|
days: (days: number) => {
|
|
418
1515
|
inPast: () => JSONSchema;
|
|
@@ -469,6 +1566,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
469
1566
|
* )
|
|
470
1567
|
*/
|
|
471
1568
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1569
|
+
/**
|
|
1570
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1571
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1572
|
+
* available inside the function body — all logic must be self-contained.
|
|
1573
|
+
*
|
|
1574
|
+
* @example
|
|
1575
|
+
* field('nid').customClientValidator((value) => {
|
|
1576
|
+
* // LUHN check — all logic must be inline
|
|
1577
|
+
* const digits = String(value).split('').map(Number)
|
|
1578
|
+
* // ...
|
|
1579
|
+
* return isValid
|
|
1580
|
+
* })
|
|
1581
|
+
*/
|
|
1582
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1583
|
+
/**
|
|
1584
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1585
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1586
|
+
* The function receives the referenced field's value as the first argument and
|
|
1587
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1588
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1589
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1590
|
+
*
|
|
1591
|
+
* For computing a default value without referencing a specific field, use
|
|
1592
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1593
|
+
*
|
|
1594
|
+
* @example
|
|
1595
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1596
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1597
|
+
* )
|
|
1598
|
+
*/
|
|
1599
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
472
1600
|
};
|
|
473
1601
|
isAfter(): {
|
|
474
1602
|
days: (days: number) => {
|
|
@@ -526,6 +1654,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
526
1654
|
* )
|
|
527
1655
|
*/
|
|
528
1656
|
object: (options: Record<string, any>) => JSONSchema;
|
|
1657
|
+
/**
|
|
1658
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
1659
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
1660
|
+
* available inside the function body — all logic must be self-contained.
|
|
1661
|
+
*
|
|
1662
|
+
* @example
|
|
1663
|
+
* field('nid').customClientValidator((value) => {
|
|
1664
|
+
* // LUHN check — all logic must be inline
|
|
1665
|
+
* const digits = String(value).split('').map(Number)
|
|
1666
|
+
* // ...
|
|
1667
|
+
* return isValid
|
|
1668
|
+
* })
|
|
1669
|
+
*/
|
|
1670
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
1671
|
+
/**
|
|
1672
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
1673
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
1674
|
+
* The function receives the referenced field's value as the first argument and
|
|
1675
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
1676
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
1677
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
1678
|
+
*
|
|
1679
|
+
* For computing a default value without referencing a specific field, use
|
|
1680
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
1681
|
+
*
|
|
1682
|
+
* @example
|
|
1683
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
1684
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
1685
|
+
* )
|
|
1686
|
+
*/
|
|
1687
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
529
1688
|
};
|
|
530
1689
|
asDob(): {
|
|
531
1690
|
$$subfield: string[];
|
|
@@ -533,17 +1692,308 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
533
1692
|
* @private Internal property used for field reference tracking.
|
|
534
1693
|
*/
|
|
535
1694
|
$$field: string;
|
|
536
|
-
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
|
+
};
|
|
537
1890
|
getByPath(fieldPath: string[]): {
|
|
538
1891
|
$$subfield: string[];
|
|
539
1892
|
/**
|
|
540
1893
|
* @private Internal property used for field reference tracking.
|
|
541
1894
|
*/
|
|
542
1895
|
$$field: string;
|
|
543
|
-
get(fieldPath: string):
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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;
|
|
547
1997
|
isAfter(): {
|
|
548
1998
|
days: (days: number) => {
|
|
549
1999
|
inPast: () => JSONSchema;
|
|
@@ -600,9 +2050,40 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
600
2050
|
* )
|
|
601
2051
|
*/
|
|
602
2052
|
object: (options: Record<string, any>) => JSONSchema;
|
|
2053
|
+
/**
|
|
2054
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2055
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2056
|
+
* available inside the function body — all logic must be self-contained.
|
|
2057
|
+
*
|
|
2058
|
+
* @example
|
|
2059
|
+
* field('nid').customClientValidator((value) => {
|
|
2060
|
+
* // LUHN check — all logic must be inline
|
|
2061
|
+
* const digits = String(value).split('').map(Number)
|
|
2062
|
+
* // ...
|
|
2063
|
+
* return isValid
|
|
2064
|
+
* })
|
|
2065
|
+
*/
|
|
2066
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2067
|
+
/**
|
|
2068
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2069
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2070
|
+
* The function receives the referenced field's value as the first argument and
|
|
2071
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2072
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2073
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2074
|
+
*
|
|
2075
|
+
* For computing a default value without referencing a specific field, use
|
|
2076
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2077
|
+
*
|
|
2078
|
+
* @example
|
|
2079
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2080
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2081
|
+
* )
|
|
2082
|
+
*/
|
|
2083
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
603
2084
|
};
|
|
604
|
-
asDob(): any;
|
|
605
|
-
asAge(): any;
|
|
2085
|
+
asDob(): /*elided*/ any;
|
|
2086
|
+
asAge(): /*elided*/ any;
|
|
606
2087
|
isAfter(): {
|
|
607
2088
|
days: (days: number) => {
|
|
608
2089
|
inPast: () => JSONSchema;
|
|
@@ -659,6 +2140,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
659
2140
|
* )
|
|
660
2141
|
*/
|
|
661
2142
|
object: (options: Record<string, any>) => JSONSchema;
|
|
2143
|
+
/**
|
|
2144
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2145
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2146
|
+
* available inside the function body — all logic must be self-contained.
|
|
2147
|
+
*
|
|
2148
|
+
* @example
|
|
2149
|
+
* field('nid').customClientValidator((value) => {
|
|
2150
|
+
* // LUHN check — all logic must be inline
|
|
2151
|
+
* const digits = String(value).split('').map(Number)
|
|
2152
|
+
* // ...
|
|
2153
|
+
* return isValid
|
|
2154
|
+
* })
|
|
2155
|
+
*/
|
|
2156
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2157
|
+
/**
|
|
2158
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2159
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2160
|
+
* The function receives the referenced field's value as the first argument and
|
|
2161
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2162
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2163
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2164
|
+
*
|
|
2165
|
+
* For computing a default value without referencing a specific field, use
|
|
2166
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2167
|
+
*
|
|
2168
|
+
* @example
|
|
2169
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2170
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2171
|
+
* )
|
|
2172
|
+
*/
|
|
2173
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
662
2174
|
};
|
|
663
2175
|
asAge(): {
|
|
664
2176
|
$$subfield: string[];
|
|
@@ -666,17 +2178,308 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
666
2178
|
* @private Internal property used for field reference tracking.
|
|
667
2179
|
*/
|
|
668
2180
|
$$field: string;
|
|
669
|
-
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
|
+
};
|
|
670
2376
|
getByPath(fieldPath: string[]): {
|
|
671
2377
|
$$subfield: string[];
|
|
672
2378
|
/**
|
|
673
2379
|
* @private Internal property used for field reference tracking.
|
|
674
2380
|
*/
|
|
675
2381
|
$$field: string;
|
|
676
|
-
get(fieldPath: string):
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
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;
|
|
680
2483
|
isAfter(): {
|
|
681
2484
|
days: (days: number) => {
|
|
682
2485
|
inPast: () => JSONSchema;
|
|
@@ -733,9 +2536,40 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
733
2536
|
* )
|
|
734
2537
|
*/
|
|
735
2538
|
object: (options: Record<string, any>) => JSONSchema;
|
|
2539
|
+
/**
|
|
2540
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2541
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2542
|
+
* available inside the function body — all logic must be self-contained.
|
|
2543
|
+
*
|
|
2544
|
+
* @example
|
|
2545
|
+
* field('nid').customClientValidator((value) => {
|
|
2546
|
+
* // LUHN check — all logic must be inline
|
|
2547
|
+
* const digits = String(value).split('').map(Number)
|
|
2548
|
+
* // ...
|
|
2549
|
+
* return isValid
|
|
2550
|
+
* })
|
|
2551
|
+
*/
|
|
2552
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2553
|
+
/**
|
|
2554
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2555
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2556
|
+
* The function receives the referenced field's value as the first argument and
|
|
2557
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2558
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2559
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2560
|
+
*
|
|
2561
|
+
* For computing a default value without referencing a specific field, use
|
|
2562
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2563
|
+
*
|
|
2564
|
+
* @example
|
|
2565
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2566
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2567
|
+
* )
|
|
2568
|
+
*/
|
|
2569
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
736
2570
|
};
|
|
737
|
-
asDob(): any;
|
|
738
|
-
asAge(): any;
|
|
2571
|
+
asDob(): /*elided*/ any;
|
|
2572
|
+
asAge(): /*elided*/ any;
|
|
739
2573
|
isAfter(): {
|
|
740
2574
|
days: (days: number) => {
|
|
741
2575
|
inPast: () => JSONSchema;
|
|
@@ -792,6 +2626,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
792
2626
|
* )
|
|
793
2627
|
*/
|
|
794
2628
|
object: (options: Record<string, any>) => JSONSchema;
|
|
2629
|
+
/**
|
|
2630
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2631
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2632
|
+
* available inside the function body — all logic must be self-contained.
|
|
2633
|
+
*
|
|
2634
|
+
* @example
|
|
2635
|
+
* field('nid').customClientValidator((value) => {
|
|
2636
|
+
* // LUHN check — all logic must be inline
|
|
2637
|
+
* const digits = String(value).split('').map(Number)
|
|
2638
|
+
* // ...
|
|
2639
|
+
* return isValid
|
|
2640
|
+
* })
|
|
2641
|
+
*/
|
|
2642
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2643
|
+
/**
|
|
2644
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2645
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2646
|
+
* The function receives the referenced field's value as the first argument and
|
|
2647
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2648
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2649
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2650
|
+
*
|
|
2651
|
+
* For computing a default value without referencing a specific field, use
|
|
2652
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2653
|
+
*
|
|
2654
|
+
* @example
|
|
2655
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2656
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2657
|
+
* )
|
|
2658
|
+
*/
|
|
2659
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
795
2660
|
};
|
|
796
2661
|
isAfter(): {
|
|
797
2662
|
days: (days: number) => {
|
|
@@ -849,6 +2714,37 @@ export declare function createFieldConditionals(fieldId: string): {
|
|
|
849
2714
|
* )
|
|
850
2715
|
*/
|
|
851
2716
|
object: (options: Record<string, any>) => JSONSchema;
|
|
2717
|
+
/**
|
|
2718
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
2719
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
2720
|
+
* available inside the function body — all logic must be self-contained.
|
|
2721
|
+
*
|
|
2722
|
+
* @example
|
|
2723
|
+
* field('nid').customClientValidator((value) => {
|
|
2724
|
+
* // LUHN check — all logic must be inline
|
|
2725
|
+
* const digits = String(value).split('').map(Number)
|
|
2726
|
+
* // ...
|
|
2727
|
+
* return isValid
|
|
2728
|
+
* })
|
|
2729
|
+
*/
|
|
2730
|
+
customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema;
|
|
2731
|
+
/**
|
|
2732
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
2733
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
2734
|
+
* The function receives the referenced field's value as the first argument and
|
|
2735
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
2736
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
2737
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
2738
|
+
*
|
|
2739
|
+
* For computing a default value without referencing a specific field, use
|
|
2740
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
2741
|
+
*
|
|
2742
|
+
* @example
|
|
2743
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
2744
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
2745
|
+
* )
|
|
2746
|
+
*/
|
|
2747
|
+
customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate;
|
|
852
2748
|
};
|
|
853
2749
|
export {};
|
|
854
2750
|
//# sourceMappingURL=conditionals.d.ts.map
|