UNPKG

rich-domain

Version:

This package provide utils file and interfaces to assistant build a complex application with domain driving design

148 lines 6.04 kB
/** * @description A utility class for validating various data types, including numbers, strings, objects, dates, and more. * Provides methods to check the type and properties of values, as well as to perform specific validations. */ export declare class Validator { private static instance; private constructor(); /** * @description Creates or retrieves the singleton instance of the `Validator` class. * @returns {Validator} The instance of the `Validator` class. */ static create(): Validator; /** * @description Checks if a character at a specified index is a special character based on ASCII codes. * @param char The character to check. * @param index The index of the character. * @returns {boolean} True if the character is a special character, false otherwise. */ private static isSpecialChar; /** * @description Checks if the provided value is an array. * @param props The value to check. * @returns {boolean} True if the value is an array, false otherwise. */ isArray(props: any): boolean; /** * @description Checks if the provided value is a string. * @param props The value to check. * @returns {boolean} True if the value is a string, false otherwise. */ isString(props: any): boolean; /** * @description Checks if the provided value is a number. * @param props The value to check. * @returns {boolean} True if the value is a number, false otherwise. */ isNumber(props: any): boolean; /** * @description Checks if the provided value is a date. * @param props The value to check. * @returns {boolean} True if the value is a date, false otherwise. */ isDate(props: any): boolean; /** * @description Checks if the provided value is an object, excluding arrays, entities, aggregates, and value objects. * @param props The value to check. * @returns {boolean} True if the value is an object, false otherwise. */ isObject(props: any): boolean; /** * @description Checks if the provided value is null. * @param props The value to check. * @returns {boolean} True if the value is null, false otherwise. */ isNull(props: any): boolean; /** * @description Checks if the provided value is undefined. * @param props The value to check. * @returns {boolean} True if the value is undefined, false otherwise. */ isUndefined(props: any): boolean; /** * @description Checks if the provided value is a boolean. * @param props The value to check. * @returns {boolean} True if the value is a boolean, false otherwise. */ isBoolean(props: any): boolean; /** * @description Checks if the provided value is a function. * @param props The value to check. * @returns {boolean} True if the value is a function, false otherwise. */ isFunction(props: any): boolean; /** * @description Checks if the provided value is an entity (but not an aggregate). * @param props The value to check. * @returns {boolean} True if the value is an entity, false otherwise. */ isEntity(props: any): boolean; /** * @description Checks if the provided value is an aggregate. * @param props The value to check. * @returns {boolean} True if the value is an aggregate, false otherwise. */ isAggregate(props: any): boolean; /** * @description Checks if the provided value is a value object. * @param props The value to check. * @returns {boolean} True if the value is a value object, false otherwise. */ isValueObject(props: any): boolean; /** * @description Checks if the provided value is a symbol. * @param props The value to check. * @returns {boolean} True if the value is a symbol, false otherwise. */ isSymbol(props: any): boolean; /** * @description Checks if the provided value is an ID instance. * @param props The value to check. * @returns {boolean} True if the value is an ID, false otherwise. */ isID(props: any): boolean; number(target: number): { isEqualTo: (value: number) => boolean; isGreaterThan: (value: number) => boolean; isLessThan: (value: number) => boolean; isLessOrEqualTo: (value: number) => boolean; isGreaterOrEqualTo: (value: number) => boolean; isSafeInteger: () => boolean; isPositive: () => boolean; isNegative: () => boolean; isEven: () => boolean; isInteger: () => boolean; isBetween: (min: number, max: number) => boolean; isBetweenOrEqual: (min: number, max: number) => boolean; }; string(target: string): { isSpecialChar: (index?: number) => boolean; hasSpecialChar: () => boolean; hasLengthGreaterThan: (length: number) => boolean; hasLengthGreaterOrEqualTo: (length: number) => boolean; hasLengthLessThan: (length: number) => boolean; hasLengthLessOrEqualTo: (length: number) => boolean; hasLengthEqualTo: (length: number) => boolean; hasLengthBetween: (min: number, max: number) => boolean; hasLengthBetweenOrEqual: (min: number, max: number) => boolean; includes: (value: string) => boolean; isEmpty: () => boolean; match: (regex: RegExp) => boolean; hasOnlyNumbers: () => boolean; hasOnlyLetters: () => boolean; isEqual: (value: string) => boolean; }; date(target: Date): { isBeforeThan: (value: Date) => boolean; isBeforeOrEqualTo: (value: Date) => boolean; isAfterNow: () => boolean; isBeforeNow: () => boolean; isBetween: (start: Date, end: Date) => boolean; isWeekend: () => boolean; isAfterThan: (value: Date) => boolean; isAfterOrEqualTo: (value: Date) => boolean; }; } declare const _default: Validator; export default _default; //# sourceMappingURL=validator.d.ts.map