import { EventDocument } from '../events/EventDocument'; import { ActionUpdate, EventState } from '../events/ActionDocument'; import { ITokenPayload as TokenPayload } from '../authentication'; import { PartialSchema as AjvJSONSchemaType } from 'ajv/dist/types/json-schema'; import { userSerializer } from '../events/serializers/user/serializer'; import { UUID } from '../uuid'; import { todayDateTimeValueSerializer } from '../events/serializers/date/serializer'; import { EventStatus } from '../events/EventMetadata'; import { CodeToEvaluate, FieldReference } from '../events/FieldConfig'; import type { ClientFunctionContext } from './validate'; /** @knipignore */ export type JSONSchema = { $id: string; readonly __nominal__type: 'JSONSchema'; }; export declare function defineConditional(schema: any): JSONSchema; export declare function defineFormConditional(schema: Record): JSONSchema; type CommonConditionalParameters = { $now: string; $online: boolean; }; export type UserConditionalParameters = CommonConditionalParameters & { $user: TokenPayload; }; export type EventConditionalParameters = CommonConditionalParameters & { $event: EventDocument; }; export type FormConditionalParameters = CommonConditionalParameters & { $form: EventState | ActionUpdate; $leafAdminStructureLocationIds?: Array<{ id: UUID; }>; }; export type EventStateConditionalParameters = CommonConditionalParameters & { $flags: string[]; $status: EventStatus; }; export type ConditionalParameters = UserConditionalParameters | EventConditionalParameters | FormConditionalParameters | EventStateConditionalParameters; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type AjvJSONSchema = AjvJSONSchemaType>; /** * Returns an empty JSON Schema object, which is treated as always valid. * * @returns {AjvJSONSchema} An empty schema object `{}` that always evaluates to true. */ export declare function alwaysTrue(): AjvJSONSchema; /** * Universal boolean connector to be used with any type of conditional. (user, event, field) * * @example and(field('foo').isEqualTo('bar'), field('baz').isUndefined()) */ export declare function and(...conditions: AjvJSONSchema[]): JSONSchema; /** * Universal boolean connector to be used with any type of conditional. (user, event, field) * * @example or(field('foo').isEqualTo('bar'), field('baz').isUndefined()) */ export declare function or(...conditions: AjvJSONSchema[]): JSONSchema; /** * Universal boolean connector to be used with any type of conditional. (user, event, field) * * @example not(field('foo').isEqualTo('bar')) */ export declare function not(condition: AjvJSONSchema): JSONSchema; /** * Returns an JSON Schema object, which is treated as always invalid. * * @returns {JSONSchema} An schema object that always evaluates to false. */ export declare function never(): JSONSchema; /** * Returns an JSON Schema object, which is treated as always valid. * * @returns {JSONSchema} An schema object that always evaluates to true. */ export declare function always(): JSONSchema; /** * Generate conditional rules for current date */ export declare const now: typeof todayDateTimeValueSerializer; /** * * Generate conditional rules for user. */ export declare const user: typeof userSerializer & { hasScope: (scope: string) => JSONSchema; hasRole: (role: string) => JSONSchema; isOnline: () => JSONSchema; locationLevel: (adminLevelId: string) => { $user: { $location: string; }; }; scope: (scope: import("../scopes").ScopeType) => { attribute: (option: import("../scopes").ScopeOptionKey) => { $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"; $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids"; }; }; jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | { $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"; $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids"; }) => { $jurisdiction: "administrativeArea" | "location" | "all" | { $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"; $option: "role" | "event" | "placeOfEvent" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids"; }; }; }; export declare function isFieldReference(value: unknown): value is FieldReference; export declare function isEventFieldReference(value: unknown): value is { $$event: string; }; /** Check if an event flag is present */ export declare function flag(flagvalue: string): JSONSchema; /** Check if an event flag is present */ export declare function status(statusValue: EventStatus): JSONSchema; /** * Generate conditional rules for a form field. * * @param fieldId - The field ID condition is applied to. * @example to combine multiple conditions, utilise connectors like `and`, `or`, `not`: * and(field('foo').isEqualTo('bar'), field('baz').isUndefined()) * */ export declare function createFieldConditionals(fieldId: string): { /** * @private Internal property used for field reference tracking. */ $$field: string; /** * @private Internal property used for solving a object path within field's value */ $$subfield: string[]; get(fieldPath: string): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; getByPath(fieldPath: string[]): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; getByPath(fieldPath: string[]): any; asDob(): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asAge(): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asDob(): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asAge(): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): { $$subfield: string[]; /** * @private Internal property used for field reference tracking. */ $$field: string; get(fieldPath: string): any; getByPath(fieldPath: string[]): any; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; asDob(): any; asAge(): any; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; isAfter(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: string | FieldReference) => JSONSchema; now: () => JSONSchema; }; isBefore(): { days: (days: number) => { inPast: () => JSONSchema; inFuture: () => JSONSchema; fromDate: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; fromNow: () => JSONSchema; }; date: (date: `${string}-${string}-${string}` | FieldReference) => JSONSchema; now: () => JSONSchema; }; isGreaterThan(value: number | FieldReference): JSONSchema; isLessThan(value: number | FieldReference): JSONSchema; isEqualTo(value: string | boolean | number | FieldReference): JSONSchema; /** * Use case: Some fields are rendered when selection is not made, or boolean false is explicitly selected. * @example field('recommender.none').isFalsy() vs not(field('recommender.none').isEqualTo(true)) * @returns whether the field is falsy (undefined, false, null, empty string) * * NOTE: For now, this only works with string, boolean, and null types. 0 is still allowed. * */ isFalsy(): JSONSchema; isUndefined(): JSONSchema; inArray(values: string[]): JSONSchema; isValidEnglishName(): JSONSchema; isValidAdministrativeLeafLevel(): JSONSchema; /** * Checks if the field value matches a given regular expression pattern. * @param pattern - The regular expression pattern to match the field value against. * @returns A JSONSchema conditional that validates the field value against the pattern. */ matches(pattern: string): JSONSchema; isBetween(min: number, max: number): JSONSchema; getId: () => { fieldId: string; }; /** * @deprecated * use field(fieldId).get(nestedProperty) instead * with 'and' combinator e.g. * and( * field('child.name').get('firstname').isEqualTo('John'), * field('child.name').get('surname').isEqualTo('Doe') * ) */ object: (options: Record) => JSONSchema; /** * Custom client-side validator. The provided function is serialised and executed * just-in-time on the client only. External references (e.g. lodash) are not * available inside the function body — all logic must be self-contained. * * @example * field('nid').customClientValidator((value) => { * // LUHN check — all logic must be inline * const digits = String(value).split('').map(Number) * // ... * return isValid * }) */ customClientValidator(validationFn: (fieldValue: unknown, context: ClientFunctionContext) => boolean): JSONSchema; /** * Custom client-side evaluation. Returns a {@link FieldReference} descriptor * that can be used as the `value` property or a DATA component entry. * The function receives the referenced field's value as the first argument and * the full form context as the second; its return value replaces the field reference. * The function is serialised and executed just-in-time on the client only. * External references (e.g. lodash) are not available inside the function body. * * For computing a default value without referencing a specific field, use * `evaluate(fn)` in the `defaultValue` property instead. * * @example * field('a').customClientEvaluation((aValue, ctx) => * Number(aValue) + Number(ctx.$form.b) * ) */ customClientEvaluation(computationFn: (fieldValue: unknown, context: ClientFunctionContext) => unknown): CodeToEvaluate; }; export {}; //# sourceMappingURL=conditionals.d.ts.map