add validation for the manifest 'Dependencies' field
This commit is contained in:
parent
4b391d631c
commit
7c76c5cad2
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
## Upcoming release
|
## Upcoming release
|
||||||
* For mod authors:
|
* For mod authors:
|
||||||
|
* Added validation for the manifest `Dependencies` field.
|
||||||
* Fixed validation for mods with version `0.0.0`.
|
* Fixed validation for mods with version `0.0.0`.
|
||||||
|
|
||||||
## 3.10.1
|
## 3.10.1
|
||||||
|
|
|
@ -188,6 +188,28 @@ namespace StardewModdingAPI.Framework.ModLoading
|
||||||
// validate ID format
|
// validate ID format
|
||||||
if (!PathUtilities.IsSlug(mod.Manifest.UniqueID))
|
if (!PathUtilities.IsSlug(mod.Manifest.UniqueID))
|
||||||
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, "its manifest specifies an invalid ID (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
|
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, "its manifest specifies an invalid ID (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
|
||||||
|
|
||||||
|
// validate dependencies
|
||||||
|
foreach (var dependency in mod.Manifest.Dependencies)
|
||||||
|
{
|
||||||
|
// null dependency
|
||||||
|
if (dependency == null)
|
||||||
|
{
|
||||||
|
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a null entry under {nameof(IManifest.Dependencies)}.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// missing ID
|
||||||
|
if (string.IsNullOrWhiteSpace(dependency.UniqueID))
|
||||||
|
{
|
||||||
|
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a {nameof(IManifest.Dependencies)} entry with no {nameof(IManifestDependency.UniqueID)} field.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// invalid ID
|
||||||
|
if (!PathUtilities.IsSlug(dependency.UniqueID))
|
||||||
|
mod.SetStatus(ModMetadataStatus.Failed, ModFailReason.InvalidManifest, $"its manifest has a {nameof(IManifest.Dependencies)} entry with an invalid {nameof(IManifestDependency.UniqueID)} field (IDs must only contain letters, numbers, underscores, periods, or hyphens).");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate IDs are unique
|
// validate IDs are unique
|
||||||
|
|
Loading…
Reference in New Issue