import { Predicate, Schema as S } from 'effect'; /** An error message for a rule: either a static string, or a function that receives the invalid value. */ export type RuleMessage = string | ((value: A) => string); /** A tuple of a predicate and error message used for field validation. */ export type Rule = readonly [Predicate.Predicate, RuleMessage]; /** Resolves a `RuleMessage` to a concrete string, applying it to the value when the message is a function. */ export declare const resolveMessage: (message: RuleMessage, value: A) => string; /** Creates a `Rule` that checks if a string meets a minimum length. */ export declare const minLength: (min: number, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string does not exceed a maximum length. */ export declare const maxLength: (max: number, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string matches a regular expression. */ export declare const pattern: (regex: RegExp, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string is a valid email format. */ export declare const email: (message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string is a valid URL format. * * By default the URL must include an `http://` or `https://` protocol. * Pass `{ requireProtocol: false }` to accept bare domains. */ export declare const url: (options?: Readonly<{ message?: RuleMessage; requireProtocol?: boolean; }>) => Rule; /** Creates a `Rule` that checks if a string begins with a specified prefix. */ export declare const startsWith: (prefix: string, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string ends with a specified suffix. */ export declare const endsWith: (suffix: string, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string contains a specified substring. */ export declare const includes: (substring: string, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string exactly matches an expected value. */ export declare const equals: (expected: string, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks if a string is one of a specified set of allowed values. */ export declare const oneOf: (values: ReadonlyArray, message?: RuleMessage) => Rule; /** Creates a `Rule` that checks an array holds at least `min` items. */ export declare const minItems: (min: number, message?: RuleMessage>) => Rule>; /** Creates a `Rule` that checks an array holds at most `max` items. */ export declare const maxItems: (max: number, message?: RuleMessage>) => Rule>; /** Creates a `Rule` that passes when the value decodes through `schema`. * * Use it to reuse a Schema you already maintain (a domain codec, a refined or * branded type you decode to on submit) as a field rule, so the rule stays in * sync with the schema instead of duplicating its logic. It does nothing a * custom rule can't, so prefer the dedicated rules for plain checks. Decoding * is synchronous: the schema must decode without running an effect. */ export declare const fromSchema: (schema: S.Codec, message: RuleMessage) => Rule; //# sourceMappingURL=rule.d.ts.map