diff --git a/Netkan/Validators/InstallValidator.cs b/Netkan/Validators/InstallValidator.cs index 140381e165..28ff98bf7c 100644 --- a/Netkan/Validators/InstallValidator.cs +++ b/Netkan/Validators/InstallValidator.cs @@ -9,36 +9,39 @@ internal sealed class InstallValidator : IValidator public void Validate(Metadata metadata) { var json = metadata.Json(); - foreach (JObject stanza in json["install"]) + if (json.ContainsKey("install")) { - string install_to = (string)stanza["install_to"]; - if (metadata.SpecVersion < v1p2 && install_to.StartsWith("GameData/")) + foreach (JObject stanza in json["install"]) { - throw new Kraken("spec_version v1.2+ required for GameData with path"); - } - if (metadata.SpecVersion < v1p12 && install_to.StartsWith("Ships/")) - { - throw new Kraken("spec_version v1.12+ required to install to Ships/ with path"); - } - if (metadata.SpecVersion < v1p16 && install_to.StartsWith("Ships/@thumbs")) - { - throw new Kraken("spec_version v1.16+ required to install to Ships/@thumbs with path"); - } - if (metadata.SpecVersion < v1p4 && stanza.ContainsKey("find")) - { - throw new Kraken("spec_version v1.4+ required for install with 'find'"); - } - if (metadata.SpecVersion < v1p10 && stanza.ContainsKey("find_regexp")) - { - throw new Kraken("spec_version v1.10+ required for install with 'find_regexp'"); - } - if (metadata.SpecVersion < v1p16 && stanza.ContainsKey("find_matches_files")) - { - throw new Kraken("spec_version v1.16+ required for 'find_matches_files'"); - } - if (metadata.SpecVersion < v1p18 && stanza.ContainsKey("as")) - { - throw new Kraken("spec_version v1.18+ required for 'as'"); + string install_to = (string)stanza["install_to"]; + if (metadata.SpecVersion < v1p2 && install_to.StartsWith("GameData/")) + { + throw new Kraken("spec_version v1.2+ required for GameData with path"); + } + if (metadata.SpecVersion < v1p12 && install_to.StartsWith("Ships/")) + { + throw new Kraken("spec_version v1.12+ required to install to Ships/ with path"); + } + if (metadata.SpecVersion < v1p16 && install_to.StartsWith("Ships/@thumbs")) + { + throw new Kraken("spec_version v1.16+ required to install to Ships/@thumbs with path"); + } + if (metadata.SpecVersion < v1p4 && stanza.ContainsKey("find")) + { + throw new Kraken("spec_version v1.4+ required for install with 'find'"); + } + if (metadata.SpecVersion < v1p10 && stanza.ContainsKey("find_regexp")) + { + throw new Kraken("spec_version v1.10+ required for install with 'find_regexp'"); + } + if (metadata.SpecVersion < v1p16 && stanza.ContainsKey("find_matches_files")) + { + throw new Kraken("spec_version v1.16+ required for 'find_matches_files'"); + } + if (metadata.SpecVersion < v1p18 && stanza.ContainsKey("as")) + { + throw new Kraken("spec_version v1.18+ required for 'as'"); + } } } } diff --git a/Tests/NetKAN/Validators/CkanValidatorTests.cs b/Tests/NetKAN/Validators/CkanValidatorTests.cs index 5e1e8eda14..e4389fdb69 100644 --- a/Tests/NetKAN/Validators/CkanValidatorTests.cs +++ b/Tests/NetKAN/Validators/CkanValidatorTests.cs @@ -18,6 +18,9 @@ public void SetUp() { ValidCkan["spec_version"] = 1; ValidCkan["identifier"] = "AwesomeMod"; + ValidCkan["name"] = "Awesome Mod"; + ValidCkan["abstract"] = "A great mod"; + ValidCkan["license"] = "GPL-3.0"; ValidCkan["version"] = "1.0.0"; ValidCkan["download"] = "https://www.awesome-mod.example/AwesomeMod.zip"; }