How many times have you reviewed a pull request in ASP.NET Core and spotted something like this?
var email = request . Email ? . Trim ( ) ; var firstName = string . IsNullOrWhiteSpace ( request . FirstName ) ? null : request . FirstName . Trim ( ) ;
Enter fullscreen mode
Exit fullscreen mode
Across enterprise .NET codebases, input canonicalization is often treated as an afterthought. It gets scattered across controllers, MediatR handlers, FluentValidation transform rules, and repository methods.
Inevitably, someone forgets a .Trim() on an endpoint:
"[email protected] " and "[email protected]" end up as duplicate accounts in your database.
An empty input "" is stored instead of a clean database NULL , breaking SQL NULL semantics.
Decomposed Unicode characters cause string equality comparisons to mysteriously fail.
To solve this, developers often reach for a global JsonConverter<string> .…