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

Error: Item cannot come after itself #1283

Closed
EvgenyOrekhov opened this issue Aug 29, 2017 · 4 comments
Closed

Error: Item cannot come after itself #1283

EvgenyOrekhov opened this issue Aug 29, 2017 · 4 comments
Assignees
Labels
bug Bug or defect
Milestone

Comments

@EvgenyOrekhov
Copy link
Contributor

Context

  • node version: 8.4.0
  • joi version: 10.6.0
  • environment (node, browser): node
  • used with (hapi, standalone, ...): standalone

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

I want to define a schema for an object with properties a and b, and I want a and b to be numbers that are not equal to one another.

const Joi = require("joi");

Joi
    .object({
        a: Joi.number(),
        b: Joi.number().invalid(Joi.ref("a"))
    })
    .validate({
        a: 123,
        b: 321
    });

Which result you had ?

An error is thrown:

Item cannot come after itself: a

What did you expect ?

No errors.

This example at RunKit: https://runkit.com/57d675ee7580c314003cf648/59a52dfce0c6b2001608a2f1

@Marsup Marsup added the bug Bug or defect label Aug 29, 2017
@Marsup Marsup self-assigned this Aug 29, 2017
@Marsup
Copy link
Collaborator

Marsup commented Aug 29, 2017

Found the bug, will fix it asap. Can it wait for joi 11 ?

@EvgenyOrekhov
Copy link
Contributor Author

@Marsup Yes.

@frodrigueza
Copy link

Can you guys explain the bug/fix? I'm getting the same error here

@Marsup Marsup added this to the 11.0.0 milestone Sep 14, 2017
@Marsup
Copy link
Collaborator

Marsup commented Sep 14, 2017

Good catch, fixed it in 11 and forgot to mention it here.

@Marsup Marsup closed this as completed Sep 14, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 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

3 participants