Skip to content

Incomplete validation message #557

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

Closed
gagle opened this issue Feb 20, 2015 · 5 comments
Closed

Incomplete validation message #557

gagle opened this issue Feb 20, 2015 · 5 comments
Assignees
Labels
breaking changes Change that can breaking existing code bug Bug or defect
Milestone

Comments

@gagle
Copy link

gagle commented Feb 20, 2015

I don't know very well if this issue should be posted in the hapi or joi repos...

Given the following payload schema:

joi.object().keys({
  a: joi.object().keys({
    c: joi.number()
  }),
  b: joi.object().keys({
    c: joi.number()
  })
})

And the given value:

{
  "a": {},
  "b": {}
}

The error message is:

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "c is required. c is required",
  "validation": {
    "source": "payload",
    "keys": ["a.c", "b.c"]
  }
}

As you can see, the message has an ambiguous meaning. This should be: "a.c is required. b.c is required".

@Marsup
Copy link
Collaborator

Marsup commented Feb 20, 2015

This is already fixed in master, can you test with that ?

@Marsup Marsup added the bug Bug or defect label Feb 20, 2015
@Marsup Marsup added this to the 6.0.0 milestone Feb 20, 2015
@Marsup Marsup self-assigned this Feb 20, 2015
@gagle
Copy link
Author

gagle commented Feb 20, 2015

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "child \"a\" fails because [child \"c\" fails because [\"c\" is required]]. child \"b\" fails because [child \"c\" fails because [\"c\" is required]]",
  "validation": {
    "source": "payload",
    "keys": ["a.c", "b.c"]
  }
}

These \" could be removed or replaced by ':

"child 'a' fails because [child 'c' fails because ['c' is required]]. child 'b' fails because [child 'c' fails because ['c' is required]]"

@Marsup
Copy link
Collaborator

Marsup commented Feb 20, 2015

Wasn't that what you expected ?

@gagle
Copy link
Author

gagle commented Feb 20, 2015

Yes, it's ok. Do you know when v6.0.0 will be published to npm?

@Marsup
Copy link
Collaborator

Marsup commented Feb 20, 2015

I still have a few breaking changes I want to make before that, but I'm not the one doing them. Rough estimate a week or 2.

@Marsup Marsup closed this as completed Feb 20, 2015
@Marsup Marsup added the breaking changes Change that can breaking existing code label Feb 22, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking changes Change that can breaking existing code bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants