-
Notifications
You must be signed in to change notification settings - Fork 809
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
Null value passes when skipMissingProperties set to true #308
Comments
any idea why this might be anyone? |
Just search the source code :-)
|
I'm having a similar issue. For example: @IsString()
@IsNotEmpty()
@IsDefined()
name: string; Those two objects would both pass validation when the validate({}, { skipMissingProperties: true})
validate({ "name": null }, { skipMissingProperties: true}) Which, in my case, triggers a database Wouldn't it make more sense if |
Some properties of my model can be However:
Solutions:
|
"skipUndefinedProperties " is right |
I really also think that handling null and undefined the same doesn't make sense! That is like handling numbers and strings the same 😄 |
People in this thread go to see the PR that could possibly solve this issue and give it a review! #353 |
temporary solution turn off and use
|
I agree |
Yes, in some APIs you want to delete null values, and i some you want to save them. These two options would give us the diversity we need. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When skipMissingProperties is set to true, if property has null value, it will not validate with IsNotEmpty decorator and null value will be forwarded to controller/service/db repo etc. and cause a crash
Source of error
Example
Json input
Part of UpdateProjectDto
Nest.js framework controller example of code which will receive poData with startDate set to null and crash at DB query...
The text was updated successfully, but these errors were encountered: