I have an API defined as follows
bool IsValid()
Now, I want to modify the API so that if the return value is false, then I need additional
information why the validation failed.
I'm looking for an elegant want to solve the problem... Here are the options I have
Option 1:
bool IsValid(ref string errorMessage)
errorMessage is updated only if the result is false
option 2:
class Result<T>
{
bool Succeeded;
T Argument;
}
Result<string> IsValid()
Option 3:
void Validate();
//throw an exception if it invalid, just return if succeeded.
I'm not comfortable with any of the options listed above. So, wondering if there is any graceful solution that I might not be aware of
regards G