Joi.date().min(Joi.ref('field')) breaks original sended object
- Dominant language
- JavaScript
- Stars
- 21.2k
- Forks
- 1.5k
- Avg merge
- 4h 57m
- Merged PRs (30d)
- 14
Description
#### Support plan
* *is this issue currently blocking your project?* (yes/no): yes
* *is this issue affecting a production system?* (yes/no): yes
#### Context
* *node version*: 19.6.0
* *module version with issue*: 17.9.1
* *last module version without issue*: i don't tested in other module
* *environment* (e.g. node, browser, native): node
* *used with* (e.g. hapi application, another framework, standalone, ...): expressjs
* *any other relevant information*:
#### What are you trying to achieve or the steps to reproduce?
```js
const Joi = require('joi');
const input = {
query: {
periodStart: "2023-02-11T14:23:03.576Z",
periodEnd: "2023-03-23T14:23:03.576Z",
}
}
const schema = Joi.object({
query: Joi.object({
periodStart: Joi.date(),
periodEnd: Joi.date().min(Joi.ref('query.periodStart')).max('now'),
}),
}).options({
allowUnknown: true,
abortEarly: false
})
await schema.validateAsync(input)
```
#### What was the result you got?
```js
const receivedResult = {
query: {}
}
```
#### What result did you expect?
```js
const expectedResult = {
query: {
periodStart: new Date("2023-02-11T14:23:03.576Z"),
periodEnd: new Date("2023-03-23T14:23:03.576Z"),
}
}
```
Contributor guide
Assessment
This issue has not been assessed yet.