github.com/Finschia/finschia-sdk@v0.48.1/x/token/class/validation.go (about)

     1  package class
     2  
     3  import (
     4  	"fmt"
     5  	"regexp"
     6  )
     7  
     8  var (
     9  	// reContractIDString must be a hex string of 8 characters long
    10  	reContractIDString = `[0-9a-f]{8,8}`
    11  	reContractID       = regexp.MustCompile(fmt.Sprintf(`^%s$`, reContractIDString))
    12  )
    13  
    14  // ValidateID returns whether the contract id is valid
    15  func ValidateID(id string) error {
    16  	if !reContractID.MatchString(id) {
    17  		return ErrInvalidContractID.Wrapf("invalid contract id: %s", id)
    18  	}
    19  	return nil
    20  }