2 ms·
I know this is pedantic but there a logical error in this validation code function validateUser(user: User) { let error = ""; for (const key of
by zengid 3y ago
I know this is pedantic but there a logical error in this validation code
function validateUser(user: User) {
let error = "";
for (const key of Object.keys(user)) {
const validate = validators[key];
error ||= validate(user[key]); // <-- only first error is assigned
}
return error;
}
// instead I would put something like this..
error += validate(user[key])