Skip to content

Commit

Permalink
Improve netkan relationship error message
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 10, 2024
1 parent d6bf6e9 commit 2035194
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Netkan/Validators/ObeysCKANSchemaValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public void Validate(Metadata metadata)
var errors = CKANSchema.schema.Validate(metadata.Json());
if (errors.Any())
{
string msg = errors
.Select(err => $"{err.Path}: {err.Kind}")
.Aggregate((a, b) => $"{a}\r\n{b}");
var msg = string.Join(", ", errors.Select(err => $"{err.Path}: {err.Kind}"));
throw new Kraken($"Schema validation failed: {msg}");
}
}
Expand Down
7 changes: 4 additions & 3 deletions Netkan/Validators/RelationshipsValidator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;

using Newtonsoft.Json.Linq;

using CKAN.Versioning;
using CKAN.NetKAN.Model;
using System.Linq;

namespace CKAN.NetKAN.Validators
{
Expand All @@ -18,7 +20,7 @@ public void Validate(Metadata metadata)
{
throw new Kraken("spec_version v1.2+ required for 'supports'");
}
foreach (JObject rel in json[relName].Cast<JObject>())
foreach (var rel in json[relName].Children<JObject>())
{
if (rel.ContainsKey("any_of"))
{
Expand Down Expand Up @@ -65,7 +67,6 @@ public void Validate(Metadata metadata)
}
}
}

}

private static readonly string[] relProps = new string[]
Expand Down

0 comments on commit 2035194

Please sign in to comment.