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

Custom message overload another one #1608

Closed
caiomajdalani opened this issue Oct 8, 2018 · 1 comment
Closed

Custom message overload another one #1608

caiomajdalani opened this issue Oct 8, 2018 · 1 comment
Assignees
Labels
feature New functionality or improvement non issue Issue is not a problem or requires changes
Milestone

Comments

@caiomajdalani
Copy link

caiomajdalani commented Oct 8, 2018

Context

  • node version: 8.12.0
  • joi version: 13.7.0
  • environment (node, browser): Node
  • used with (hapi, standalone, ...): Express-joi 0.3.1

What are you trying to achieve or the steps to reproduce ?

tax: joi.object({
                    fee: joi
                        .number()
                        .integer()
                        .positive()
                        .required()
                        .error(
                        () =>
                            `property fee is required and it must be a positive integer number.`,
                    ),
                    mdr: joi
                        .number()
                        .integer()
                        .positive()
                        .required()
                        .error(
                        () =>
                            `property mdr is required and it must be a positive integer number.`,
                    ),
                })
                .required()
                .error(() => `property tax is required`),

Request

"tax": {
"fee": -1,
"mdr": 0
}

Which result you had ?

"child "tax" fails because [property tax is required]"

What did you expect ?

child "tax" fails because [child "fee" fails because [property fee is required and it must be a positive integer number.]]

@Marsup Marsup self-assigned this Nov 25, 2018
@Marsup Marsup added non issue Issue is not a problem or requires changes request labels Nov 25, 2018
@Marsup Marsup added this to the 14.2.0 milestone Nov 25, 2018
@Marsup Marsup closed this as completed in afa8af2 Nov 25, 2018
@Marsup
Copy link
Collaborator

Marsup commented Nov 25, 2018

Duplicate of #1528 so same answer. Added a new syntax to support that use case as people don't seem to understand what error does.

@hueniverse hueniverse added feature New functionality or improvement and removed request labels Sep 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New functionality or improvement non issue Issue is not a problem or requires changes
Projects
None yet
Development

No branches or pull requests

3 participants