Joi.ref is breaking
See original GitHub issueSchema:
const schema = Joi.object()
.label('SignUp')
.keys({
password: Joi.string()
.required()
.description('The password of the authenticating user')
.example('test-PASSWORD123'),
repeatPassword: Joi.string()
.required()
.allow(Joi.ref('password'))
.description('Repeat the password to ensure no typos')
.example('test-PASSWORD123')
});
Result:
joi-to-typescript/dist/main/utils.js:26
return `'${value.replace(/\\/g, '\\\\').replace(/'/g, "\\'")}'`;
^
TypeError: value.replace is not a function
at toStringLiteral (joi-to-typescript/dist/main/utils.js:26:22)
at joi-to-typescript/dist/main/parse.js:341:92
at Array.map (<anonymous>)
at parseStringSchema (joi-to-typescript/dist/main/parse.js:339:42)
at parseHelper (joi-to-typescript/dist/main/parse.js:189:20)
at parseSchema (joi-to-typescript/dist/main/parse.js:265:26)
at joi-to-typescript/dist/main/parse.js:423:30
at joi-to-typescript/dist/main/utils.js:13:27
at Array.reduce (<anonymous>)
at filterMap (joi-to-typescript/dist/main/utils.js:12:17)
Shape returned at this line:
{ ref: { path: [ 'password' ] } }
Is it possible for me to just skip all processing on this field using a meta flag or something?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Using Joi.valid(Joi.ref('password')) breaks the endpoint form ...
Using Joi.string().valid(Joi.ref('password')); gives a drop-down with a single weird value that doesn't pass the validation on swagger's UI.
Read more >How to validate sum of refs in Joi - Stack Overflow
ref . I can do the following and hang a custom off the entire validation schema, but would prefer to attach it to...
Read more >Changelog - joi.dev
Joi valid fails, when ref is used with a stripped key. 10.2.2 · #1103. allow param defaults to be set by the param...
Read more >How to use the joi.ref function in joi - Snyk
To help you get started, we've selected a few joi.ref examples, based on popular ways it is used in public projects.
Read more >Chapter 6: Validations with Joi | Hapi With Typescript - Softcover
Some users may send in invalid input because of ignorance; othes might do it on purpose to break the application. Instead of assuming...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🤯 - Holy cow! You resolved that so fast. Thank you so much! Also, please don’t let any of the people on things I maintain know that you can fix things this fast 😆 😭
fixed released under 4.0.3