@livyn/time
Version:
A lightweight, efficient, and modular time utility for formatting timestamps, retrieving timezones, and working with time-related data in JavaScript/Node.js projects.
14 lines (13 loc) • 466 B
JavaScript
/**
* Validates the provided format string.
*
* Ensures the format is a non-empty string. Throws an error if validation fails.
*
* @param {string} format - The format string to validate.
* @throws {TypeError} If the format is not a string or is an empty string after trimming.
*/
export default function validateFormat(format) {
if (typeof format !== 'string' || format.trim() === '') {
throw new TypeError('Format must be a non-empty string');
}
}