Check version on init for PluginDependency

This commit is contained in:
Him188 2020-11-24 10:17:06 +08:00
parent 06895e2a6d
commit b2ad961e8d

View File

@ -46,6 +46,7 @@ public data class PluginDependency @JvmOverloads constructor(
init {
kotlin.runCatching {
PluginDescription.checkPluginId(id)
if (versionRequirement != null) SemVersion.parseRangeRequirement(versionRequirement)
}.getOrElse {
throw IllegalArgumentException(it)
}
@ -63,7 +64,10 @@ public data class PluginDependency @JvmOverloads constructor(
public override fun toString(): String = buildString {
append(id)
versionRequirement?.let(::append)
versionRequirement?.let {
append(":")
append(it)
}
if (isOptional) {
append('?')
}