Skip to content

Error: Item cannot come after itself #1283

@EvgenyOrekhov

Description

@EvgenyOrekhov

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

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions