MCPcopy Create free account
hub / github.com/opencontainers/go-digest / Validate

Method Validate

algorithm.go:179–193  ·  view source on GitHub ↗

Validate validates the encoded portion string

(encoded string)

Source from the content-addressed store, hash-verified

177
178// Validate validates the encoded portion string
179func (a Algorithm) Validate(encoded string) error {
180 r, ok := anchoredEncodedRegexps[a]
181 if !ok {
182 return ErrDigestUnsupported
183 }
184 // Digests much always be hex-encoded, ensuring that their hex portion will
185 // always be size*2
186 if a.Size()*2 != len(encoded) {
187 return ErrDigestInvalidLength
188 }
189 if r.MatchString(encoded) {
190 return nil
191 }
192 return ErrDigestInvalidFormat
193}

Callers

nothing calls this directly

Calls 1

SizeMethod · 0.95

Tested by

no test coverage detected