import { BaseLiteralType } from '../base/literal.js'; import { IS_OF_TYPE, SUBTYPE, UNIQUE_NAME } from '../../symbols.js'; import type { Validation, AlphaOptions, FieldContext, FieldOptions, AlphaNumericOptions, NormalizeEmailOptions } from '../../types.js'; import { urlRule, uuidRule, emailRule, mobileRule, passportRule, creditCardRule, postalCodeRule, normalizeUrlRule, vatRule } from './rules.js'; /** * VineString represents a string value in the validation schema. * It provides comprehensive string validation with built-in rules * for common patterns like email, URL, UUID, and more. * * @example * const schema = vine.string() * .email() * .minLength(5) * .maxLength(100) * * const result = await vine.validate({ * schema, * data: 'user@example.com' * }) */ export declare class VineString extends BaseLiteralType { /** * Static collection of all available validation rules for strings */ static rules: { in: (options: { choices: string[] | ((field: FieldContext) => string[]); }) => Validation<{ choices: string[] | ((field: FieldContext) => string[]); }>; jwt: (options?: undefined) => Validation; url: (options?: import("validator/lib/isURL.js").IsURLOptions | undefined) => Validation; iban: (options?: undefined) => Validation; uuid: (options?: { version?: (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8)[]; } | undefined) => Validation<{ version?: (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8)[]; } | undefined>; ulid: (options?: undefined) => Validation; trim: (options?: undefined) => Validation; email: (options?: import("validator/lib/isEmail.js").IsEmailOptions | undefined) => Validation; alpha: (options?: AlphaOptions | undefined) => Validation; ascii: (options?: undefined) => Validation; notIn: (options: { list: string[] | ((field: FieldContext) => string[]); }) => Validation<{ list: string[] | ((field: FieldContext) => string[]); }>; regex: (options: RegExp) => Validation; escape: (options?: undefined) => Validation; sameAs: (options: { otherField: string; }) => Validation<{ otherField: string; }>; mobile: (options?: import("../../types.js").MobileOptions | ((field: FieldContext) => import("../../types.js").MobileOptions | undefined) | undefined) => Validation import("../../types.js").MobileOptions | undefined) | undefined>; string: (options?: undefined) => Validation; hexCode: (options?: undefined) => Validation; passport: (options: import("../../types.js").PassportOptions | ((field: FieldContext) => import("../../types.js").PassportOptions)) => Validation import("../../types.js").PassportOptions)>; endsWith: (options: { substring: string; }) => Validation<{ substring: string; }>; confirmed: (options?: { confirmationField?: string; } | { as?: string; } | undefined) => Validation<{ confirmationField?: string; } | { as?: string; } | undefined>; activeUrl: (options?: undefined) => Validation; minLength: (options: { min: number; }) => Validation<{ min: number; }>; notSameAs: (options: { otherField: string; }) => Validation<{ otherField: string; }>; maxLength: (options: { max: number; }) => Validation<{ max: number; }>; vat: (options: import("../../types.js").VATOptions | ((field: FieldContext) => import("../../types.js").VATOptions)) => Validation import("../../types.js").VATOptions)>; ipAddress: (options?: { version: 4 | 6; } | undefined) => Validation<{ version: 4 | 6; } | undefined>; creditCard: (options?: import("../../types.js").CreditCardOptions | ((field: FieldContext) => import("../../types.js").CreditCardOptions | void | undefined) | undefined) => Validation import("../../types.js").CreditCardOptions | void | undefined) | undefined>; postalCode: (options?: import("../../types.js").PostalCodeOptions | ((field: FieldContext) => import("../../types.js").PostalCodeOptions | void | undefined) | undefined) => Validation import("../../types.js").PostalCodeOptions | void | undefined) | undefined>; startsWith: (options: { substring: string; }) => Validation<{ substring: string; }>; toUpperCase: (options?: string | string[] | undefined) => Validation; toLowerCase: (options?: string | string[] | undefined) => Validation; toCamelCase: (options?: undefined) => Validation; fixedLength: (options: { size: number; }) => Validation<{ size: number; }>; coordinates: (options?: undefined) => Validation; normalizeUrl: (options?: import("normalize-url").Options | undefined) => Validation; alphaNumeric: (options?: AlphaOptions | undefined) => Validation; normalizeEmail: (options?: import("validator").NormalizeEmailOptions | undefined) => Validation; }; /** * The subtype identifier for the literal schema field */ [SUBTYPE]: string; /** * Unique name identifier for union type resolution */ [UNIQUE_NAME]: string; /** * Type checker function to determine if a value is a string. * Required for "unionOfTypes" functionality. * * @param value - The value to check * @returns True if the value is a string */ [IS_OF_TYPE]: (value: unknown) => value is string; /** * Creates a new VineString instance with optional configuration. * * @param options - Field options like bail mode and nullability * @param validations - Initial set of validations to apply */ constructor(options?: FieldOptions, validations?: Validation[]); /** * Validates the value to be a valid URL. * * @param args - Optional URL validation options * @returns This string schema instance for method chaining */ url(...args: Parameters): this; /** * Validates the value to be an active URL by making an HTTP request. * * @returns This string schema instance for method chaining */ activeUrl(): this; /** * Validates the value to be a valid email address. * * @param args - Optional email validation options * @returns This string schema instance for method chaining */ email(...args: Parameters): this; /** * Validates the value to be a valid mobile phone number for specified locales. * * @param options - Optional mobile validation options including locale and strictMode * @returns This string schema instance for method chaining * * @example * vine.string().mobile({ locale: ['en-US', 'en-GB'] }) */ mobile(...args: Parameters): this; /** * Validates the value to be a valid VAT (Value Added Tax) number for specified countries. * * @param options - VAT validation options including country codes * @returns This string schema instance for method chaining * * @example * vine.string().vat({ countryCode: ['FR', 'CH', 'VE'] }) */ vat(...args: Parameters): this; /** * Validates the value to be a valid IP address (IPv4 or IPv6). * * @param version - Optional IP version (4 for IPv4, 6 for IPv6). Omit to allow both. * @returns This string schema instance for method chaining * * @example * vine.string().ipAddress() // Allows IPv4 and IPv6 * vine.string().ipAddress(4) // Only IPv4 * vine.string().ipAddress(6) // Only IPv6 */ ipAddress(version?: 4 | 6): this; /** * Validates the value to be a valid hexadecimal color code. * * @returns This string schema instance for method chaining * * @example * vine.string().hexCode() // Accepts #FFF, #FFFFFF, etc. */ hexCode(): this; /** * Validates the value against a custom regular expression pattern. * * @param expression - The regular expression to match against * @returns This string schema instance for method chaining * * @example * vine.string().regex(/^[A-Z]{3}\d{3}$/) // Matches ABC123 pattern */ regex(expression: RegExp): this; /** * Validates the value to contain only alphabetic characters. * * @param options - Options to allow spaces, underscores, or dashes * @returns This string schema instance for method chaining * * @example * vine.string().alpha() * vine.string().alpha({ allowSpaces: true }) * vine.string().alpha({ allowSpaces: true, allowDashes: true }) */ alpha(options?: AlphaOptions): this; /** * Validates the value to contain only alphanumeric characters (letters and numbers). * * @param options - Options to allow spaces, underscores, or dashes * @returns This string schema instance for method chaining * * @example * vine.string().alphaNumeric() * vine.string().alphaNumeric({ allowSpaces: true, allowUnderscores: true }) */ alphaNumeric(options?: AlphaNumericOptions): this; /** * Enforce a minimum length on a string field. * * @param expectedLength - The minimum required length * @returns This string schema instance for method chaining */ minLength(expectedLength: number): this; /** * Enforce a maximum length on a string field. * * @param expectedLength - The maximum allowed length * @returns This string schema instance for method chaining */ maxLength(expectedLength: number): this; /** * Enforce a fixed length on a string field. * * @param expectedLength - The exact required length * @returns This string schema instance for method chaining */ fixedLength(expectedLength: number): this; /** * Ensures the field is confirmed by having another field with "_confirmation" suffix * (or a custom suffix). Useful for password confirmation fields. * * @param options - Optional configuration for the confirmation field name * @returns This string schema instance for method chaining * * @example * // Validates that "password_confirmation" field matches "password" * vine.string().confirmed() * * @example * // Custom confirmation field name * vine.string().confirmed({ as: 'passwordConfirm' }) */ confirmed(options?: { /** * @deprecated * Use "as" field instead */ confirmationField?: string; } | { as?: string; }): this; /** * Trims leading and trailing whitespace from the string value. * * @returns This string schema instance for method chaining * * @example * vine.string().trim() // " hello " becomes "hello" */ trim(): this; /** * Normalizes the email address by applying transformations like * lowercasing and removing dots from Gmail addresses. * * @param options - Email normalization options * @returns This string schema instance for method chaining * * @example * vine.string().email().normalizeEmail({ gmail_remove_dots: true }) */ normalizeEmail(options?: NormalizeEmailOptions): this; /** * Converts the field value to UPPERCASE. * * @returns This string schema instance for method chaining * * @example * vine.string().toUpperCase() // "hello" becomes "HELLO" */ toUpperCase(): this; /** * Converts the field value to lowercase. * * @returns This string schema instance for method chaining * * @example * vine.string().toLowerCase() // "HELLO" becomes "hello" */ toLowerCase(): this; /** * Converts the field value to camelCase. * * @returns This string schema instance for method chaining * * @example * vine.string().toCamelCase() // "hello_world" becomes "helloWorld" */ toCamelCase(): this; /** * Escapes HTML entities in the string to prevent XSS attacks. * * @returns This string schema instance for method chaining * * @example * vine.string().escape() // "