Treating empty string in form post as null for nullable value types by nvmkpk · Pull Request #52499 · dotnet/aspnetcore (original) (raw)
Adding proper parsing of empty string from form post for a nullable field
The changes treat the empty string as null
Description
Form post sends empty string for an empty input field but NullableConverter
does not handle that and just uses corresponding non-nullable converter to parse and fails. This PR updates that to convert the empty string to corresponding type's null value.
Fixes #52195
Customer Impact
Without these changes, we cannot define an optional value type field (like DateOnly
) when not using any interactive rendering modes.
Regression?
- Yes
- No
Risk
- High
- Medium
- Low
Verification
- Manual (required)
- Automated
Packaging changes reviewed?
- Yes
- No
- N/A
When servicing release/2.1
- Make necessary changes in eng/PatchConfig.props
Fixes #52195