feat: added nyc for test coverage reporting. fix: add jsdoc comments

This commit is contained in:
StevanFreeborn
2023-01-26 13:58:25 -06:00
parent b36d9445bd
commit 8b6e5ccefc
10 changed files with 2993 additions and 27 deletions
+41 -12
View File
@@ -1,17 +1,46 @@
/**
* @class ArgumentValidator - A class that validates arguments.
*/
export class ArgumentValidator {
public static isNullOrWhiteSpace(value: string | null | undefined): boolean {
return value === null || value === undefined || (/^\s*$/).test(value);
/**
* @param {string} value - The value to validate.
* @returns {boolean} - True if the value is null, undefined, or a string that contains only whitespace characters; otherwise, false.
*/
public static isNullOrWhiteSpace(value: string | null | undefined): boolean {
return value === null || value === undefined || /^\s*$/.test(value);
}
/**
* @param {string} value - The value to validate.
* @returns {boolean} - True if the value is a valid URL; otherwise, false.
*/
public static isValidUrl(value: string | null | undefined): boolean {
let url: URL;
try {
url = new URL(value);
} catch (error) {
return false;
}
public static isValidUrl(value: string | null | undefined): boolean {
let url: URL;
return url.protocol === 'http:' || url.protocol === 'https:';
}
try {
url = new URL(value);
} catch (error) {
return false;
}
/**
* @param {number} value - The value to validate.
* @returns {boolean} - True if the value is a valid page size; otherwise, false.
* @remarks - A valid page size is a number greater than 0 and less than or equal to 1000.
*/
public static isValidPageSize(value: number): boolean {
return value > 0 && value <= 1000;
}
return url.protocol === 'http:' || url.protocol === 'https:';
}
}
/**
* @param {number} value - The value to validate.
* @returns {boolean} - True if the value is a valid page number; otherwise, false.
* @remarks - A valid page number is a number greater than 0.
*/
public static isValidPageNumber(value: number): boolean {
return value > 0;
}
}