UNPKG

@stacksjs/ts-validation

Version:

A simple TypeScript starter kit using Bun.

75 lines (74 loc) 2.68 kB
import type { alphanumeric } from '../lib/isAlphanumeric'; import type { LengthValidator, Validator } from './base'; import type isEmail from '../lib/isEmail'; import type isURL from '../lib/isURL'; export declare interface ContainsOptions { ignoreCase?: boolean minOccurrences?: number } export declare interface AlphanumericOptions { ignore?: string | RegExp locale?: LocaleInstance } export declare interface IsEmptyOptions { ignoreWhitespace?: boolean } export declare interface IsFQDNOptions { allow_trailing_dot?: boolean | string allow_wildcard?: boolean | string require_tld?: boolean | string allow_numeric_tld?: boolean | string ignore_max_length?: number allow_underscores?: boolean | string } export declare interface IsLengthOptions { min?: number max?: number discreteLengths?: boolean | string } export declare interface IsURLOptions { protocols?: string[] require_tld?: boolean require_protocol?: boolean require_host?: boolean require_port?: boolean require_valid_protocol?: boolean allow_underscores?: boolean allow_trailing_dot?: boolean allow_protocol_relative_urls?: boolean allow_fragments?: boolean allow_query_components?: boolean validate_length?: boolean max_allowed_length?: number host_whitelist?: (string | RegExp)[] host_blacklist?: (string | RegExp)[] disallow_auth?: boolean } export declare interface NormalizeEmailOptions { gmail_remove_subaddress?: boolean | string gmail_remove_dots?: boolean | string all_lowercase?: boolean | string gmail_lowercase?: boolean | string gmail_convert_googlemaildotcom?: boolean | string icloud_remove_subaddress?: boolean | string icloud_lowercase?: boolean | string outlookdotcom_remove_subaddress?: boolean | string outlookdotcom_lowercase?: boolean | string yahoo_remove_subaddress?: boolean | string yahoo_lowercase?: boolean | string yandex_lowercase?: boolean | string yandex_convert_yandexru?: boolean | string } export declare interface StringValidatorType extends Validator<string>, LengthValidator<StringValidatorType> { email: (options?: Parameters<typeof isEmail>[1]) => StringValidatorType url: (options?: Parameters<typeof isURL>[1]) => StringValidatorType matches: (pattern: RegExp) => StringValidatorType equals: (param: string) => StringValidatorType alphanumeric: () => StringValidatorType alpha: () => StringValidatorType numeric: () => StringValidatorType custom: (fn: (value: string | null | undefined) => boolean, message: string) => StringValidatorType } export declare interface TextValidatorType extends StringValidatorType { } export type LocaleInstance = keyof typeof alphanumeric