When casting a primitive to the domain type, it skip the NormalizeInput stage
Steps to reproduce
[ValueObject<string>(Conversions.SystemTextJson | Conversions.TypeConverter, // Support for System.Text.Json and TypeConverter for a smooth serialization and deserialization
toPrimitiveCasting: CastOperator.Implicit, // Implicit casting from Email to string
fromPrimitiveCasting: CastOperator.Implicit)] // Implicit casting from string to Email
public partial struct PhoneInternationalPrefix
{
private static string NormalizeInput(string input) => input switch
{
null => string.Empty,
[var c] when IsNumber(c) => $"+{input}",
[var c] => input, // not valid, will be caught by the regex validation
[var start,.., var end] when IsWhiteSpace(start) || IsWhiteSpace(end) => NormalizeInput(input.Trim()),
[var c,..] when c != '+' => $"+{input}",
_ => input
};
}
Describe the bug
When casting a primitive to the domain type, it skip the
NormalizeInput
stageSteps to reproduce
Expected behaviour
Cast should goes through
From(value)
I Think that the following code on this location
Should be altered to: