import { type ValidationLevel, type ValidationState } from "./_helpers.mjs"; import type { CustomObject } from "./custom-object.mjs"; import { type ExistingManifestContextOptions } from "./existing-manifest-context.mjs"; import type { Field } from "./field.mjs"; import type { ManifestComponentDeletion } from "./manifest-builder.mjs"; export interface ValidationDeletionIdentifier { ruleId: string; modelRqlName: string; } /** * Initialization properties for {@link Validation}. */ export interface ValidationProps { /** * Display name of this validation rule shown in the UI. * * Required. */ displayName: string; /** * RQL formula that returns `true` when the record is **invalid**. * * Required. Note the violation semantics: a truthy result triggers the error, * not a passing check. Example: `'(end_time__c <= start_time__c)'` fires when * end is not after start. */ rqlFormula: string; /** * User-facing error message shown when the validation fires. * * Required. Pass an empty string for no message. */ errorMessage: string; /** * Whether this rule is active or inactive. * * Required. One of `'ACTIVE'` | `'INACTIVE'`. */ state: ValidationState; /** * Whether the error is shown at the record level or on a specific field. * * Required. One of `'RECORD'` | `'FIELD'`. When `'FIELD'`, also set `fieldRef`. */ level: ValidationLevel; /** * Internal description of this rule (for developer reference only). * * Required. Pass an empty string if unused. */ ruleDescription: string; /** * Stable identifier for this rule. Pass a human-readable slug * (e.g. `'gym_session_end_after_start'`) to keep it stable across regenerations. * * Optional. Auto-generated when omitted. @default generateId('rule') */ ruleId?: string; /** * The field the error is pinned to. Typically paired with `level: 'FIELD'`. * * Optional. */ fieldRef?: Field; } export interface ValidationLoadFromExistingOptions extends ExistingManifestContextOptions { customObjectApiName?: string; } /** * Defines a validation rule and registers it with the manifest. * * A validation rule evaluates an RQL formula on save and blocks the operation * when the formula returns `true`. You would normally define validations after * the fields they reference. * * **Violation semantics:** the formula encodes the *invalid* condition, not the * valid one. `'(end_time__c <= start_time__c)'` fires when end is before or equal * to start — i.e., it is truthy when the record is wrong. * * @example * ```ts * new Validation(sessionObj, { * ruleId: 'gym_session_end_after_start', * displayName: 'End time must be after start', * rqlFormula: '(end_time__c <= start_time__c)', * errorMessage: 'End time must be after the start time.', * ruleDescription: 'Prevents zero-length or inverted intervals', * state: 'ACTIVE', * level: 'FIELD', * fieldRef: sessionEndField, * }); * ``` */ export declare class Validation { static readonly componentType: "CUSTOM_OBJECT_VALIDATION_RULE"; static toDeletionIdentifier(identifier: ValidationDeletionIdentifier): ManifestComponentDeletion; private readonly _ruleId; private readonly _customObjectApiName; private readonly _displayName; private readonly _rqlFormula; private readonly _errorMessage; private readonly _state; private readonly _level; private readonly _ruleDescription; private readonly _fieldRef; /** * @param customObject - The custom object this rule applies to. * @param props - Initialization properties. */ constructor(customObject: CustomObject, props: ValidationProps); /** * Loads this validation rule from the active existing-manifest JSON context. */ static loadFromExisting(ruleId: string, options?: ValidationLoadFromExistingOptions): Validation; /** @internal Hydrates a validation rule from existing manifest wire JSON. */ static _fromExistingComponent(customObject: CustomObject, component: Record, resolveField: (apiName: string) => Field): Validation; /** * Returns the stable identifier for this validation rule (e.g. `'gym_session_end_after_start'`). */ getRuleId(): string; /** * Returns the api_name of the custom object this validation rule applies to. */ getCustomObjectApiName(): string; /** * Serializes this validation rule to the wire format consumed by the manifest install endpoint. * * @returns A plain object with `type: 'CUSTOM_OBJECT_VALIDATION_RULE'`. * `field_rql_name` is omitted when `fieldRef` was not provided. */ toDict(): Record; } //# sourceMappingURL=validation.d.mts.map