hapijs / hapijs/joi

Multi flag on some rules

Open
#2,457 5 comments 0 reactions 1 assignee Claimed by @brianle1301 View on GitHub
documentation
Dominant language
JavaScript
Stars
21.2k
Forks
1.5k
Avg merge
4h 57m
Merged PRs (30d)
14

Description

#### 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:
```js
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](https://img.shields.io/badge/multi-blue.svg)](#multi) `[![multi](https://img.shields.io/badge/multi-blue.svg)](#multi)` pointing to new seciton in docs about overwriting/appending rules

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.