Joi.Forbidden() should prevent property from being output in typescript
See original GitHub issueWhen Forbidden and/or Strip is used, the resulting typescript model should not have the entry defined in its model.
export const examplePOSTBodySchema = baseSchema
.fork(['id'], (x) => x.forbidden().strip(true))
.meta({className: 'examplePOSTBody'});
Here I am forking a base schema and trying to remove the id parameter. Unfortunately Forbidden is not supported so id is still output in the resulting model.
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
17.7.0 API Reference - joi.dev
Validates a value against a schema, returns valid object, and throws if validation fails where: value - the value to validate. schema -...
Read more >TypeScript Joi: Property 'validate' does not exist on type 'Root'
To Validate, you can use this code below: schema.validateAsync({ email, password, fullName }).then(val => { req.body = val; }).catch(err ...
Read more >How to use the joi.forbidden function in joi - Snyk
Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately. var uuid = require('node-uuid'); var...
Read more >joi-to-typescript - npm
This will allow you to use generate TypeScript interfaces from Joi Schemas that can be used to assign types to JavaScript objects or...
Read more >21.1.0 API Reference - hapi.dev
Plugin-specific configuration which can later be accessed via server.settings.plugins . plugins is an object where each key is a plugin name and the...
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
I have a scenario where I use
Joi.forbidden()
to indicate that the value should beundefined
.So my expected behaviour would be:
With this in mind, I think
Joi.forbidden()
should actually compile to:Any thoughts on this? Currently it just compiles to
any
, which I think is wrong.This doesn’t work in latest version (not tested 4.0.0).
This:
Produces this: