❔ FluentValidation DTO
Hello, lets say I have a dto like this:
When the user supplies a request, if he doesn't supply center id it will be auto initialized to 0, making it impossible to detect if he even supplied that property
The solution is making the property nullable and checking if .NotNull()
however then IDE cries for nullables so we come to this:
Is this the correct way to setup DTOs?
3 Replies
If 0 isn't a valid value for CenterId, it doesn't matter the it gets defaulted to 0, you can validate with with
NotEmpty
Oh I didn't know NotEmpty works on numbers, ty
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.