Disable validation for dto properties not working
See original GitHub issueHi, I have a Dto with a property name Guid, I want set this property in server side, so I set this attribute with DisableValidation attribute and pass this dto from angular with guid value empty string. but i got status code 400 (bad request). what is solution for my scenario?
C#
public class ContentEntityBaseDto : FullAuditedEntityDto<int>
{
[DisableValidation]
public Guid Guid { get; set; } = Guid.NewGuid();
}
angular:
export abstract class ContentEntityBase extends FullAuditedEntityBase {
guid: string = '';
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Unable to disable javax.persistence.validation in ...
We are using SpringBoot version 2.7.9, in which I am trying to switch off the automatic validation of the DTOs. However, this does...
Read more >Remove Dto Validation - architectural change #10
Hi,. I think there are two types of validation: Simply validating format of the DTO properties, like it should not be empty ([Required]) ......
Read more >Spring Boot DTO Validation Example
In this tutorial, we will learn how to validate Spring boot REST API DTO requests ... @NotNull validates that the annotated property value...
Read more >Validation | NestJS - A progressive Node.js framework
skipUndefinedProperties, boolean, If set to true then validator will skip validation of all properties that are undefined in the validating object.
Read more >Validation with Spring Boot - the Complete Guide
If for any reason we want to disable Bean Validation in our Spring Data repositories, we can set the Spring Boot property spring.jpa.properties....
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 FreeTop 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
Top GitHub Comments
BTW, if it will be always null, then just don’t add it to your DTO. This would be a better design.
[DisableValidation] works for ABP. But a non-null Guid (a value type) is considered as “required” and MVC validation marks it as invalid. Even we (somehow, I don’t know) handle it with ABP, your ModelState.IsValid will be still false. So, you should make it nullable if you allow nulls to set by clients. This is the true design. Other solutions will be just workarounds.