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

feat(rest): add support for ajv-errors #4623

Merged
merged 4 commits into from
Feb 12, 2020

Conversation

mastermunj
Copy link
Contributor

@mastermunj mastermunj commented Feb 11, 2020

Implements #2146

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

👉 Check out how to submit a PR 👈

Copy link
Member

@achrinza achrinza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @mastermunj! Not sure if it's out-of-scope but I think we'll need some documentation on the new feature. Maybe we could add the docs under Model > Property decorator or Error handling.

@mastermunj
Copy link
Contributor Author

mastermunj commented Feb 11, 2020

@mastermunj mastermunj requested a review from achrinza February 11, 2020 16:35
@jannyHou jannyHou self-assigned this Feb 11, 2020
@@ -190,6 +191,7 @@ function createValidator(
{},
{
allErrors: true,
jsonPointers: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it needed for ajv-errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, allErrors & jsonPointers both are needed by ajv-errors as documented in their usage docs.

When not provided, they're enabled from within ajv-errors at https://github.com/epoberezkin/ajv-errors/blob/master/index.js#L4-L8

Benefits of jsonPointers are listed at ajv errors -> Templates

@@ -333,7 +333,7 @@ describe('validateRequestBody', () => {
it('nested $ref in reference', () => {
const details: RestHttpErrors.ValidationErrorDetails[] = [
{
path: '.accounts[0].address.city',
path: '/accounts/0/address/city',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it introduced by jsonPointers: true,?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is because of jsonPointers: true

Copy link
Member

@achrinza achrinza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants