MCPcopy Index your code
hub / github.com/modelcontextprotocol/registry / validateVersion

Function validateVersion

internal/validators/validators.go:335–361  ·  view source on GitHub ↗

validateVersion validates the version string. NB: we decided that we would not enforce strict semver for version strings

(ctx *ValidationContext, version string)

Source from the content-addressed store, hash-verified

333// validateVersion validates the version string.
334// NB: we decided that we would not enforce strict semver for version strings
335func validateVersion(ctx *ValidationContext, version string) *ValidationResult {
336 result := &ValidationResult{Valid: true, Issues: []ValidationIssue{}}
337
338 if version == "latest" {
339 issue := NewValidationIssueFromError(
340 ValidationIssueTypeSemantic,
341 ctx.String(),
342 ErrReservedVersionString,
343 "reserved-version-string",
344 )
345 result.AddIssue(issue)
346 return result
347 }
348
349 // Reject semver range-like inputs
350 if looksLikeVersionRange(version) {
351 issue := NewValidationIssueFromError(
352 ValidationIssueTypeSemantic,
353 ctx.String(),
354 fmt.Errorf("%w: %q", ErrVersionLooksLikeRange, version),
355 "version-looks-like-range",
356 )
357 result.AddIssue(issue)
358 }
359
360 return result
361}
362
363// looksLikeVersionRange detects common semver range syntaxes and wildcard patterns.
364// that indicate the value is not a single, specific version.

Callers 2

ValidateServerJSONFunction · 0.85
validatePackageFieldFunction · 0.85

Calls 4

AddIssueMethod · 0.95
looksLikeVersionRangeFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…