Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

abortEarrly = false and formatting the return of multiple errors #3008

Open
TomMiller-mas opened this issue Dec 20, 2023 · 1 comment
Open
Labels
support Questions, discussions, and general support

Comments

@TomMiller-mas
Copy link

Runtime

node 18, express 4

Runtime version

18, 4 latest on both

Module version

17.7.0"

Used with

express.js

Any other relevant information

It seems to daisy chain the errors into one long string. Is there a way to have them on their own line? /n or
added the string of multiple error messages string.

How can we help?

  try {
    const inputVal = await schemaGetCustProdQuery.validateAsync(inputData, {
      abortEarly: false,
    });
    return inputVal;
  } catch (err) {
    return `${err}`.replace("ValidationError:", "Validation Error:");
  }
@TomMiller-mas TomMiller-mas added the support Questions, discussions, and general support label Dec 20, 2023
@Marsup
Copy link
Collaborator

Marsup commented Feb 21, 2024

Hi,

Right now there is not, although it wouldn't be very hard to add that to the errors options. What you can do though is recreate that from the details:

return `Validation Error: ${err.details.map((detail) => detail.message).join('\n')}`

Is it enough for your needs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

2 participants