github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/packages/container/oci/reference.go (about)

     1  // Copyright 2023 The GitBundle Inc. All rights reserved.
     2  // Copyright 2017 The Gitea Authors. All rights reserved.
     3  // Use of this source code is governed by a MIT-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package oci
     7  
     8  import (
     9  	"regexp"
    10  )
    11  
    12  var referencePattern = regexp.MustCompile(`\A[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}\z`)
    13  
    14  type Reference string
    15  
    16  func (r Reference) Validate() bool {
    17  	return referencePattern.MatchString(string(r))
    18  }