Skip to content

Improve error message #812

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
catalint opened this issue Jan 28, 2016 · 6 comments
Closed

Improve error message #812

catalint opened this issue Jan 28, 2016 · 6 comments
Assignees
Labels
bug Bug or defect
Milestone

Comments

@catalint
Copy link

"use strict"

const Joi = require('joi')

const moves = {
    like: 'jagger',
    true: 'maybe'
}

const def = Joi.object({
    true: Joi.string().valid('maybe')
})


// OK
console.log(String(def.validate(moves).error))
// ValidationError: "like" is not allowed

// NOT OK
console.log(String(def.label('Moves').validate(moves).error))
// ValidationError: "Moves" is not allowed

// EXPECTED

// ValidationError: "like" is not allowed for "Moves"
// OR AT LEAST
// ValidationError: "like" is not allowed
@Marsup
Copy link
Collaborator

Marsup commented Jan 28, 2016

Root can't really have a label since it doesn't have a name in javascript, there's no path to access it.

@catalint
Copy link
Author

Don't really understand what you are referring to as root and the fact that it doesn't have label?

The above code works, and the validation is wotking also, but the error generated now is missleading if the object has a label.

Can you confirm the issue?

@Marsup
Copy link
Collaborator

Marsup commented Jan 28, 2016

I see, misinterpreted your report, it's already been fixed in 7.2.2, which version are you running ?

@catalint
Copy link
Author

Unfortunately I'm using 7.2.2 and seeing this

@Marsup Marsup added the bug Bug or defect label Jan 29, 2016
@Marsup Marsup self-assigned this Jan 29, 2016
@Marsup Marsup added this to the 7.2.3 milestone Jan 29, 2016
@Marsup
Copy link
Collaborator

Marsup commented Jan 29, 2016

Confirmed, I'll fix it in a while, just noticed 7.2.2 actually introduced a bug.

@Marsup Marsup closed this as completed in d5f1686 Jan 29, 2016
@catalint
Copy link
Author

catalint commented Feb 1, 2016

thanks !

@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
bug Bug or defect
Projects
None yet
Development

No branches or pull requests

2 participants