export type ValidationErrorDetails = Readonly<{ kind: 'custom'; message: string; } | { kind: 'template-literal'; } | { kind: 'enum'; values: readonly unknown[]; } | { kind: 'integer-range'; start: number; endExclusive: number; } | { kind: 'integer-range-inclusive'; start: number; endInclusive: number; } | { kind: 'tuple-length'; expectedLength: number; actualLength: number; } | { kind: 'array-length'; expectedLength: number; actualLength: number; } | { kind: 'array-min-length'; minLength: number; actualLength: number; } | { kind: 'array-max-length'; maxLength: number; actualLength: number; } | { kind: 'array-range-length'; minLength: number; maxLength: number; actualLength: number; } | { kind: 'non-empty-array'; } | { kind: 'missing-key'; key: string; } | { kind: 'excess-key'; key: string; } | { kind: 'intersection'; typeNames: readonly string[]; } | { kind: 'union'; typeNames: readonly string[]; } | { kind: 'union-category-mismatch'; memberCount: number; memberCategories: readonly string[]; } | { kind: 'union-closest-member'; memberCount: number; /** The member whose errors follow the message. */ closestMemberTypeName: string; /** * Members that produced the same number of errors as * {@link ValidationErrorDetails.closestMemberTypeName} and are therefore * just as plausible. Empty when the closest member is unambiguous. */ equallyCloseMemberTypeNames: readonly string[]; } | { kind: 'record-entry'; entry: 'key' | 'value'; expectedType: string; } | { kind: 'map-entry'; entry: 'key' | 'value'; expectedType: string; } | { kind: 'set-element'; expectedType: string; } | { kind: 'brand'; description: string; } | { kind: 'string-constraint'; violation: StringConstraintViolation; } | { kind: 'numeric-constraint'; numericType: 'bigint' | 'number'; violation: NumericConstraintViolation; }>; /** * Describes which `string` constraint (see the `string` codec) a value failed, * together with the constraint's configured value. `value` doubles as the * value shown in the constructor-time "defaultValue ... does not satisfy the * constraint ..." message, so it mirrors the raw constraint input (the flag * constraints carry `true`, `regex` carries its `source`). */ export type StringConstraintViolation = Readonly<{ constraint: 'nonempty' | 'lowercase' | 'uppercase'; value: true; } | { constraint: 'minLength' | 'maxLength'; value: number; } | { constraint: 'startsWith' | 'endsWith' | 'includes'; value: string; } | { constraint: 'regex'; value: string; }>; /** * Describes which numeric constraint (see the `number` / `bigint` codecs) a * value failed. Range bounds are stringified so a single type can describe both * `number` and `bigint` violations; `value` doubles as the value shown in the * constructor-time "defaultValue ... does not satisfy the constraint ..." * message. */ export type NumericConstraintViolation = Readonly<{ constraint: 'finite' | 'int' | 'safeInteger' | 'nonZero' | 'negative' | 'nonNegative' | 'positive' | 'nonPositive'; value: true; } | { constraint: 'gt' | 'gte' | 'min' | 'lt' | 'lte' | 'max' | 'multipleOf' | 'step'; value: string; }>; /** * Represents a validation error with structured information */ export type ValidationError = Readonly<{ /** The path to the field that failed validation (e.g., 'user.address.street') */ path: readonly string[]; /** The actual value that failed validation */ actualValue: unknown; /** The expected type or constraint */ expectedType: string; /** The name of the type that was being validated */ typeName: string; /** Optional structured information used to construct a descriptive message */ details?: ValidationErrorDetails | undefined; }>; /** * Converts a validation error to a human-readable string message */ export declare const validationErrorToMessage: (error: ValidationError, maxLengthToPrintActualValue?: number) => string; /** * Human-readable name for the runtime type of a value. * * `typeof` reports a bare `"object"` for `null` and for every non-primitive, * which makes an error message unable to distinguish a plain object from * `null` or from the basic containers, so those are named individually. */ export declare const runtimeTypeNameOf: (value: unknown) => string; /** * Maximum length of the ` | `-joined listing of union member type names that a * message may spell out. Beyond it a listing is more noise than help, so both * users of this bound summarize instead: `union` switches from listing every * member to reporting the closest one, and the closest-member message stops * naming the members that tie with it. */ export declare const UNION_MEMBER_LISTING_MAX_LENGTH = 60; /** * Converts an array of validation errors to an array of string messages * (for backward compatibility) */ export declare const validationErrorsToMessages: (errors: readonly ValidationError[], maxLengthToPrintActualValue?: number) => readonly string[]; /** * Prepends a path segment to all validation errors */ export declare const prependPathToValidationErrors: (errors: readonly ValidationError[], pathSegment: string) => readonly ValidationError[]; /** * Prepends an array index to all validation errors */ export declare const prependIndexToValidationErrors: (errors: readonly ValidationError[], index: number) => readonly ValidationError[]; /** * Creates a basic validation error for primitive type validation */ export declare const createPrimitiveValidationError: ({ actualValue, expectedType, typeName, details, }: Readonly<{ actualValue: unknown; expectedType: string; typeName: string; details: ValidationErrorDetails | undefined; }>) => ValidationError; //# sourceMappingURL=validation-error.d.mts.map