UNPKG

@jdlien/validator-utils

Version:

Validation and sanitization functions used by @jdlien/Validator.

61 lines (60 loc) 2.78 kB
/** * Utilities used by the Validator class. * * @format */ type DateParts = { year: number; month: number; day: number; }; export declare function isFormControl(el: any): boolean; interface ValidationResult { valid: boolean; error?: boolean; messages: string[]; } export declare function isType(el: HTMLInputElement | HTMLTextAreaElement, types: string | string[]): boolean; export declare function momentToFPFormat(format: string): string; export declare function monthToNumber(str: string | number): number; export declare function yearToFull(year: number | string): number; export declare function parseDate(value: string | Date): Date; export declare function guessDatePart(num: number, knownMeanings?: (string | null)[]): string[]; export declare function guessDateParts(str: string): DateParts; export declare function parseTime(value: string): { hour: number; minute: number; second: number; } | null; export declare function parseTimeToString(value: string, format?: string): string; export declare function parseDateTime(value: string | Date): Date | null; export declare function formatDateTime(date: Date | string, format?: string): string; export declare function parseDateToString(value: string | Date, format?: string): string; export declare function parseDateTimeToString(value: string | Date, format?: string): string; export declare function isDate(value: string | Date): boolean; export declare function isDateTime(value: string | Date): boolean; export declare function isDateInRange(date: Date, range: string): boolean; export declare function isMeridiem(token: string): boolean; export declare function isTime(value: string): boolean; export declare function isEmail(value: string): boolean; export declare function parseNANPTel(value: string): string; export declare function isNANPTel(value: string): boolean; export declare function parseInteger(value: string): string; export declare function isNumber(value: string): boolean; export declare function parseNumber(value: string): string; export declare function isInteger(value: string): boolean; export declare function parseUrl(value: string): string; export declare function isUrl(value: string): boolean; export declare function parseZip(value: string): string; export declare function isZip(value: string): boolean; export declare function parsePostalCA(value: string): string; export declare function isPostalCA(value: string): boolean; export declare function isColor(value: string): boolean; export declare function parseColor(value: string): string; export declare function normalizeValidationResult(res: boolean | string | { valid: boolean; message?: string; messages?: string | string[]; error?: boolean; }): ValidationResult; export {};