Skip to content

Commit

Permalink
bettrer validation error format
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Sep 15, 2022
1 parent e9d2792 commit aebf953
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/DotNetStac/Schemas/StacValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,15 @@ private bool ValidateJObject(JObject jObject)
internal static string FormatMessage(ValidationError validationError, string prefix)
{
StringBuilder message = new StringBuilder();
message.AppendFormat(prefix + "[{0},{1}]", validationError.LineNumber, validationError.LinePosition);
message.Append(prefix);
if (validationError.LineNumber > 1 && validationError.LinePosition > 1)
{
message.AppendFormat("[{0},{1}]", validationError.LineNumber, validationError.LinePosition);
}
else
{
message.AppendFormat("[ROOT]");
}
if (!string.IsNullOrEmpty(validationError.Path))
{
message.AppendFormat(" Path '{0}'", validationError.Path);
Expand Down

0 comments on commit aebf953

Please sign in to comment.