Skip to content

Validate a number, which depends on other validate numbers #667

@SteffenGorenflo

Description

@SteffenGorenflo

I want to validate a number, which depends on other values. I tried something like the following:

var schema = {
  a: Joi.number().
  b: Joi.number()

  c: Joi.number().max(Joi.ref('a') + Joi.ref('b'))
};

In this case c should not be greater than the value of a + b.

If I run this code, I get

Error: limit must be a number or reference

Metadata

Metadata

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions