Create an error from multiple errors
94
Build a validation error reporter that collects multiple validation errors from different data fields and produces a well-formatted consolidated error report.
Your task is to implement a validation error reporter for a data processing system. When validating records with multiple fields, validation can fail on several fields simultaneously. Instead of stopping at the first error, the system should collect all validation errors and report them together in a clean, readable format.
Implement a function validateRecord(record) that:
email, age, and usernameemail: Must contain an '@' symbolage: Must be a number between 0 and 120username: Must be at least 3 characters longtrueThe consolidated error should display all validation failures in a clean, indented format that makes it easy to identify which validations failed.
@generates
/**
* Validates a record object with email, age, and username fields.
*
* @param {Object} record - The record to validate
* @param {string} record.email - Email address
* @param {number} record.age - Age value
* @param {string} record.username - Username
* @returns {boolean} Returns true if all validations pass
* @throws {Error} Throws a consolidated error with all validation failures
*/
function validateRecord(record) {
// IMPLEMENTATION HERE
}
module.exports = { validateRecord };Provides error aggregation and formatting capabilities.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-aggregate-errordocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9