File tree 1 file changed +16
-0
lines changed
Sources/PackageDescription 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,10 @@ public struct Version {
60
60
/// - patch: The patch version number.
61
61
/// - prereleaseIdentifiers: The pre-release identifier.
62
62
/// - buildMetaDataIdentifiers: Build metadata that identifies a build.
63
+ ///
64
+ /// - Precondition: `major >= 0 && minor >= 0 && patch >= 0`.
65
+ /// - Precondition: `prereleaseIdentifiers` can conatin only ASCII alpha-numeric characters and "-".
66
+ /// - Precondition: `buildMetaDataIdentifiers` can conatin only ASCII alpha-numeric characters and "-".
63
67
public init (
64
68
_ major: Int ,
65
69
_ minor: Int ,
@@ -68,6 +72,18 @@ public struct Version {
68
72
buildMetadataIdentifiers: [ String ] = [ ]
69
73
) {
70
74
precondition ( major >= 0 && minor >= 0 && patch >= 0 , " Negative versioning is invalid. " )
75
+ precondition (
76
+ prereleaseIdentifiers. allSatisfy {
77
+ $0. allSatisfy { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) }
78
+ } ,
79
+ #"Pre-release identifiers can contain only ASCII alpha-numeric characters and "-"."#
80
+ )
81
+ precondition (
82
+ buildMetadataIdentifiers. allSatisfy {
83
+ $0. allSatisfy { $0. isASCII && ( $0. isLetter || $0. isNumber || $0 == " - " ) }
84
+ } ,
85
+ #"Build metadata identifiers can contain only ASCII alpha-numeric characters and "-"."#
86
+ )
71
87
self . major = major
72
88
self . minor = minor
73
89
self . patch = patch
You can’t perform that action at this time.
0 commit comments