Vogen
Vogen copied to clipboard
TryFrom - add overload returning validation result
Describe the feature
Currently, it's possible to use the validation result only if you use the ErrorOr overload:
var result = FilePath.TryFrom("X:/test");
if (!result.IsSuccess)
{
Console.Out.WriteLine("Validation error occurred: {0}", result.Error.ErrorMessage);
}
An overload could be added so the boolean version of TryFrom also returns the validation result - as an out parameter:
if (!FilePath.TryFrom("X:/test", out var filePath, out var validationResult))
{
Console.Out.WriteLine("Validation error occurred: {0}", validationResult.ErrorMessage);
}
I find the latter to be a lot more convenient to write. I am new to this repository, please let me know if this does not align with the vision or might not be a good idea for certain reasons. I can contribute.
Thank you!
Thanks for the feedback! I think that would make a useful addition.