hapijs / hapijs/joi

Joi does not work with application with Custom Prototypes

Open
#3,031 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
21.2k
Forks
1.5k
Avg merge
4h 57m
Merged PRs (30d)
14

Description

### Runtime

node

### Runtime version

v20.12.1

### Module version

17.12.3

### Last module version without issue

14.3.1

### Used with

standalone

### Any other relevant information

_No response_

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

I took the liberty to create a proof of concept => https://stackblitz.com/edit/nodejs-server-1krq6c?file=server.js.
I was upgrading an application (too old) and because of this that are several prototypes implemented that are affecting the new versions of joi.

### What was the result you got?

The error below:
```shell
/joi-test/node_modules/joi/lib/base.js:800
target.$_terms[key] = this.$_terms[key] ? this.$_terms[key].slice() : null;
^

TypeError: this.$_terms[key].slice is not a function
at internals.Base._assign (/joi-test/node_modules/joi/lib/base.js:800:73)
at exports.type (/joi-test/node_modules/joi/lib/extend.js:17:25)
at internals.Base.extend (/joi-test/node_modules/joi/lib/base.js:451:23)
at Object. (/joi-test/node_modules/joi/lib/types/any.js:13:23)
at Module._compile (node:internal/modules/cjs/loader:1369:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
at Module.load (node:internal/modules/cjs/loader:1206:32)
at Module._load (node:internal/modules/cjs/loader:1022:12)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:179:18)
```

### What result did you expect?

the same behavior as the older versions, I was able to use joi normally without error

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.