UNPKG

@speedup/string-to

Version:

Convert all the string variables into their actual data type using different parsers

52 lines (51 loc) 1.77 kB
/** * Date parser */ import { Parser as IParser } from '../type/parser'; export declare class Parser implements IParser<Date> { /** * Validate string and check whether its possible to parse as date * @param val String value to parse * @param options No option is accepted */ validateSync(val?: string, options?: void): boolean; /** * Validate string and check whether its possible to parse as date * @param val String value to parse * @param options No option is accepted */ validate(val?: string, options?: void): Promise<boolean>; /** * Parse a string into a date * @param val String value to parse * @param options No option is accepted */ parseSync(val?: string, options?: void): Date; /** * Parse a string into a date * @param val String value to parse * @param options No option is accepted */ parse(val?: string, options?: void): Promise<Date>; /** * Validate and parse the value * @param val String value to parse * @param defaultValue Default value for the time that the value is not parsable * @param options No option is accepted */ validateAndParseSync(val?: string, defaultValue?: Date, options?: { validatorOptions?: void; parserOptions?: void; }): Date | undefined; /** * Validate and parse the value * @param val String value to parse * @param defaultValue Default value for the time that the value is not parsable * @param options No option is accepted */ validateAndParse(val?: string, defaultValue?: Date, options?: { validatorOptions?: void; parserOptions?: void; }): Promise<Date | undefined>; } export declare const parser: Parser;