-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using log4net; | ||
using CKAN.NetKAN.Model; | ||
using CKAN.NetKAN.Services; | ||
|
||
namespace CKAN.NetKAN.Validators | ||
{ | ||
internal sealed class KrefValidator : IValidator | ||
{ | ||
public KrefValidator() { } | ||
|
||
public void Validate(Metadata metadata) | ||
{ | ||
Log.Info("Validating that metadata contains valid or null $kref"); | ||
|
||
switch (metadata.Kref?.Source) | ||
{ | ||
case null: | ||
case "curse": | ||
case "github": | ||
case "http": | ||
case "jenkins": | ||
case "netkan": | ||
case "spacedock": | ||
// We know this $kref, looks good | ||
break; | ||
|
||
default: | ||
// Anything not in the above list won't trigger a Transformer | ||
throw new Kraken($"Invalid $kref: {metadata.Kref}"); | ||
} | ||
|
||
} | ||
|
||
private static readonly ILog Log = LogManager.GetLogger(typeof(KrefValidator)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters