UNPKG

@decaf-ts/decorator-validation

Version:
76 lines (75 loc) 3.47 kB
/** * Validates whether two values are eligible for comparison using >= or <= operators. * * Supported types: `undefined`, `number`, `bigint`, and `Date`. * * @param a - The first value to compare. * @param b - The second value to compare. * * @returns {boolean} True if both values are of supported types. * * @throws {TypeError} If either value is of an unsupported type. * @memberOf module:decorator-validation */ export declare function isValidForGteOrLteComparison(a: any, b: any): boolean; /** * @summary Compares two values to determine if the first is less than the second. * @description Supports numbers and dates. Throws an error for unsupported types. * * @param {any} a - The first value to compare. * @param {any} b - The second value to compare against. * * @returns {boolean} True if `a` is less than `b`, false otherwise. * * @throws {Error} If either `a` or `b` is `null` or `undefined`. * @throws {TypeError} If values are of mismatched or unsupported types. * @memberOf module:decorator-validation */ export declare function isLessThan(a: any, b: any): boolean; /** * Checks if `a` is greater than `b`. * Supports comparison for numbers and Date objects. * * @param {any} a - The value to validate. * @param {any} b - The value to compare against. * * @returns {boolean} True if `a` is greater than `b`, otherwise false. * * @throws {Error} If either `a` or `b` is `null` or `undefined`. * @throws {TypeError} If values are of mismatched or unsupported types. * @memberOf module:decorator-validation */ export declare function isGreaterThan(a: any, b: any): boolean; /** * @description Checks if a value matches a specified type name * @summary Utility function to verify if a value's type matches the provided type name * @param {unknown} value - The value to check the type of * @param {string} acceptedType - The type name to check against * @return {boolean} Returns true if the value matches the accepted type, false otherwise */ export declare function checkType(value: unknown, acceptedType: string): boolean; /** * @description Checks if a value matches any of the specified type names * @summary Utility function to verify if a value's type matches any of the provided type names * @param {unknown} value - The value to check the type of * @param {string[]} acceptedTypes - Array of type names to check against * @return {boolean} Returns true if the value matches any of the accepted types, false otherwise */ export declare function checkTypes(value: unknown, acceptedTypes: string[]): boolean; /** * @description Evaluates if a value matches the specified type metadata * @summary Compares a value against type metadata to determine if they match * @param {unknown} value - The value to evaluate * @param {string | string[] | {name: string}} types - Type metadata to check against, can be a string, array of strings, or an object with a name property * @return {boolean} Returns true if the value matches the type metadata, false otherwise */ export declare function evaluateDesignTypes(value: unknown, types: string | string[] | { name: string; }): boolean; /** * @description Returns the length of a value * @summary Returns the length of a value * @param {string | Set<any> | any[] | Map<any, any>} value - The value to evaluate * @return {number} Returns the length of a value */ export declare function valueLength(value: string | Set<any> | any[] | Map<any, any>): number;