UNPKG

unqommented

Version:

A Node.js utility that quickly identifies files with uncommented code in your codebase. Designed for developers who want to efficiently tell LLMs exactly which files need comments added.

28 lines (25 loc) 933 B
/** * @file Input validation utilities * @description Provides functions for validating various types of input data * @module validation-utils */ const validator = require('validator'); const localVars = require('../config/localVars'); /** * @function validateEmail * @description Validates an email address using the 'validator' library. * @rationale Leveraging a well-tested library like 'validator' is a security best practice. * It provides robust email validation, protecting the system from invalid or malicious data. * @param {string} email - The email address to validate. * @returns {boolean} True if the email is valid, false otherwise. * @throws {Error} If the email parameter is not a string. */ function validateEmail(email) { if (typeof email !== 'string') { throw new Error(localVars.ERROR_MESSAGES.EMAIL_NOT_STRING); } return validator.isEmail(email); } module.exports = { validateEmail, };