Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question: default value forbidUnknownValues #2317

Closed
aashutoshrathi opened this issue Nov 24, 2023 · 10 comments · Fixed by #2322
Closed

question: default value forbidUnknownValues #2317

aashutoshrathi opened this issue Nov 24, 2023 · 10 comments · Fixed by #2322
Labels
type: documentation Issues related to improving the documentation.

Comments

@aashutoshrathi
Copy link
Contributor

I was trying to...
see if forbidUnknownValues is true by default in 0.14.0

The problem:
In docs it still says
Fails validation for objects unknown to class-validator. Defaults to false

@aashutoshrathi aashutoshrathi added the type: question Questions about the usage of the library. label Nov 24, 2023
@braaar
Copy link
Member

braaar commented Nov 24, 2023

Could you point to the exact file and line you are referring to? I can't seem to find what you are referring to.

@aashutoshrathi
Copy link
Contributor Author

* Fails validation for objects unknown to class-validator. Defaults to false.

@braaar
Copy link
Member

braaar commented Nov 24, 2023

That is a past version of the source code from a year ago.

@aashutoshrathi
Copy link
Contributor Author

which branch has the latest code?

@braaar
Copy link
Member

braaar commented Nov 24, 2023

develop. I'll consider this issue settled

@braaar braaar closed this as not planned Won't fix, can't repro, duplicate, stale Nov 24, 2023
@braaar braaar added status: cannot reproduce Bug reports which cannot be reproduced. status: invalid / expired Issues with no action to take. and removed status: cannot reproduce Bug reports which cannot be reproduced. labels Nov 24, 2023
@aashutoshrathi
Copy link
Contributor Author

aashutoshrathi commented Nov 24, 2023

develop. I'll consider this issue settled

I might be completely wrong here, but isn't this the code from develop.

/**
* Fails validation for objects unknown to class-validator. Defaults to false.
*
* For instance, since a plain empty object has no annotations used for validation:
* - `validate({})` // passes
* - `validate({}, { forbidUnknownValues: true })` // fails.
* - `validate(new SomeAnnotatedEmptyClass(), { forbidUnknownValues: true })` // passes.
*/
forbidUnknownValues?: boolean;

And for the context, I'm just talking about doc strings.

Example here (using v0.14.0):
image

Thanks for actively replying and apologies for being PITA

@brnkes
Copy link

brnkes commented Nov 27, 2023

I noticed the same discrepancy. Seems like a typo ?

Changelog (0.14.0) implies that forbidUnknownValues is enabled by default & #1798 implements a true-by-default logic.

However, ValidatorOptions' JSDoc suggests otherwise. e252183 is the last commit for ValidatorOptions and it is also what the most recently published package (0.14.0) includes.

@braaar
Copy link
Member

braaar commented Nov 28, 2023

I stand corrected! This is indeed a typo.

@braaar braaar reopened this Nov 28, 2023
@braaar braaar added type: documentation Issues related to improving the documentation. and removed status: invalid / expired Issues with no action to take. type: question Questions about the usage of the library. labels Nov 28, 2023
@braaar
Copy link
Member

braaar commented Nov 28, 2023

PR welcome :)

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: documentation Issues related to improving the documentation.
Development

Successfully merging a pull request may close this issue.

3 participants