Skip to content

@jimka/typescript-ui / validation / ValidationRule

Type Alias: ValidationRule ​

ts
type ValidationRule = 
  | {
  message: string;
  type: "required";
 }
  | {
  message: string;
  min: number;
  type: "minLength";
 }
  | {
  max: number;
  message: string;
  type: "maxLength";
 }
  | {
  message: string;
  min: number;
  type: "min";
 }
  | {
  max: number;
  message: string;
  type: "max";
 }
  | {
  message: string;
  pattern: RegExp;
  type: "regex";
 }
  | {
  message: string;
  predicate: (value: unknown) => boolean;
  type: "custom";
};

Defined in: src/typescript/lib/validation/ValidationRule.ts:14

A discriminated union of all supported validation rule types.

Each variant carries a message override that is shown in the error tooltip when the rule fails. If omitted, a sensible default message is used.