Skip to content

References for Number comparisons? #560

@DavidTPate

Description

@DavidTPate

Looking through the docs it looks like references are supported for min/max for Dates:

var schema = Joi.object({
  from: Joi.date().required(),
  to: Joi.date().min(Joi.ref('from')).required()
});

But I'm not seeing the equivalent available for Numbers. So

var schema = Joi.object({
  minLength: Joi.number().required(),
  maxLength: Joi.number().min(Joi.ref('minLength')).required()
});

Throws an error due to limit not being an integer. The same thing occurs for the following uses: Number.min(), Number.max(), Number.greater(), Number.less()

Is this functionality not yet supported or is there some other way for me to compare two numeric values via a reference?

Metadata

Metadata

Assignees

Labels

featureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions