MCPcopy Create free account
hub / github.com/Masterminds/semver / validatePrerelease

Function validatePrerelease

version.go:743–758  ·  view source on GitHub ↗

From the spec, "Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers MUST NOT include leading zeroes.". These segments can be dot separated.

(p string)

Source from the content-addressed store, hash-verified

741// Numeric identifiers MUST NOT include leading zeroes.". These segments can
742// be dot separated.
743func validatePrerelease(p string) error {
744 eparts := strings.Split(p, ".")
745 for _, p := range eparts {
746 if p == "" {
747 return ErrInvalidPrerelease
748 } else if containsOnly(p, num) {
749 if len(p) > 1 && p[0] == '0' {
750 return ErrSegmentStartsZero
751 }
752 } else if !containsOnly(p, allowed) {
753 return ErrInvalidPrerelease
754 }
755 }
756
757 return nil
758}
759
760// From the spec, "Build metadata MAY be denoted by
761// appending a plus sign and a series of dot separated identifiers immediately

Callers 6

TestValidatePrereleaseFunction · 0.85
StrictNewVersionFunction · 0.85
NewVersionFunction · 0.85
coerceNewVersionFunction · 0.85
SetPrereleaseMethod · 0.85
validateVersionFunction · 0.85

Calls 1

containsOnlyFunction · 0.85

Tested by 1

TestValidatePrereleaseFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…