zitadel/internal/eventstore/v2/repository/version.go

21 lines
442 B
Go
Raw Normal View History

2020-09-30 08:00:05 +00:00
package repository
import (
"regexp"
"github.com/caos/zitadel/internal/errors"
)
var versionRegexp = regexp.MustCompile(`^v[0-9]+(\.[0-9]+){0,2}$`)
2020-10-06 19:28:09 +00:00
//Version represents the semver of an aggregate
2020-09-30 08:00:05 +00:00
type Version string
2020-10-06 19:28:09 +00:00
//Validate checks if the v is semver
2020-09-30 08:00:05 +00:00
func (v Version) Validate() error {
if !versionRegexp.MatchString(string(v)) {
return errors.ThrowPreconditionFailed(nil, "MODEL-luDuS", "version is not semver")
}
return nil
}