Skip to content

Multi flag on some rules #2457

Open
Open
@zuozp8

Description

@zuozp8

Context

  • node version: v14.8
  • module version: v17.2

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

In joi v15 i could apply greater contraint twice and both were evaluated during validation:

const schema = Joi.object({
  from: Joi.date().required(),
  to: Joi.date().greater(Joi.ref('from')).greater('now').required()
})
schema.validate({from: '2099-05-02', to: '2099-05-01'})
// { error: Error [ValidationError]: child "to" fails because ["to" must be greater than "Sat May 02 2099 00:00:00 GMT+0000 (Coordinated Universal Time)"]…

currently in v17.2 this validation passes, as greater('now') overwrites greater(Joi.ref('from'))

I looked into the code and I see flag multi: true in some rules like any.custom or 'string.pattern', it should be documented.

For example those rules could get badge multi [![multi](https://img.shields.io/badge/multi-blue.svg)](#multi) pointing to new seciton in docs about overwriting/appending rules

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions