In Collection2, how to access all the validation error? I get only the first one


#1

Hi, I’m trying to get all the error messages. But when I run the following code :

Committees.insert({name, shortName, seats, description, ctp1, ctp2, pdtp1, pdtp2, pdtp3 }, (error, result) => {
  console.log(error);
});

It will only return the first validation error. How can I get all the validations in something like an array so I can display them in the site? (The reason I can’t use auto-form is that I use React :-)) @aldeed


#2

See the What Happens When The Document Is Invalid? section of the Collection2 docs:

The error message for the first invalid key is set in the error.message, and the full invalidKeys array is available on error.invalidKeys.


#3

Great thanks! Just managed to get an array of errors!