ts-valid8
Version:
A next-generation TypeScript validation library with advanced features
74 lines • 2.24 kB
TypeScript
import { BaseSchema } from '../core/schema';
import { ValidationContext, ValidationResult } from '../core/types';
/**
* StringSchema - Advanced string validation with rich pattern matching
* and complex rule composition
*/
export declare class StringSchema extends BaseSchema<string> {
_type: string;
private _patterns;
private _transformers;
protected validateType(value: unknown, context: ValidationContext): ValidationResult<string>;
protected clone(): StringSchema;
/**
* Require the string to have a minimum length
*/
min(length: number, message?: string): StringSchema;
/**
* Require the string to have a maximum length
*/
max(length: number, message?: string): StringSchema;
/**
* Require the string to have an exact length
*/
length(length: number, message?: string): StringSchema;
/**
* Require the string to match a regular expression
*/
pattern(regex: RegExp, message?: string): StringSchema;
/**
* Require the string to be a valid email
*/
email(message?: string): StringSchema;
/**
* Require the string to be a valid URL
*/
url(message?: string): StringSchema;
/**
* Require the string to be a valid UUID
*/
uuid(message?: string): StringSchema;
/**
* Complex password validation with multiple rules
* Allows customization of requirements
*/
password(options?: {
minLength?: number;
requireLowercase?: boolean;
requireUppercase?: boolean;
requireNumbers?: boolean;
requireSpecialChars?: boolean;
customMessage?: string;
}): StringSchema;
/**
* Transforms the string value to uppercase
*/
toUpperCase(): StringSchema;
/**
* Transforms the string value to lowercase
*/
toLowerCase(): StringSchema;
/**
* Trim the string value
*/
trim(): StringSchema;
/**
* Apply a custom transformation to the string
*/
transform(fn: (value: string) => string): StringSchema;
/**
* Require the string to be one of the allowed values
*/
oneOf(values: string[], message?: string): StringSchema;
}
//# sourceMappingURL=string.d.ts.map