Skip to content

Commit

Permalink
Add ToString override for ValidatorResult
Browse files Browse the repository at this point in the history
  • Loading branch information
imaun committed Nov 30, 2022
1 parent d94e73e commit 3254f79
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Validations/ValidatorResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,35 @@ private void AddInfo(ValidationInfo info)
_infos.Add(info);
_items.Add(info);
}



public override string ToString()
{
var sb = new StringBuilder();
if (HasError)
{
sb.AppendLine("[Errors]:");
foreach (var err in _errors)
sb.AppendLine(err.ToString());
sb.AppendLine("");
}

if (HasWarning)
{
sb.AppendLine("[Warnings]:");
foreach (var w in _warnings)
sb.AppendLine(w.ToString());
sb.AppendLine("");
}

if (_infos.Any())
{
sb.AppendLine("[Info]:");
foreach (var i in _infos)
sb.AppendLine(i.ToString());
sb.AppendLine("");
}

return sb.ToString();
}
}

0 comments on commit 3254f79

Please sign in to comment.