Files
lincodex/backend/internal/domain/mail_retry.go
T

19 lines
721 B
Go

package domain
import "regexp"
var mailRetryActorPattern = regexp.MustCompile(`^operator:[a-z0-9][a-z0-9._-]*$`)
// MailRetryActor identifies an operator who authorized a retry of an unknown
// delivery. It is a handle, not an account ID, email address, or credential.
type MailRetryActor string
// ParseMailRetryActor accepts an operator handle in the form
// "operator:<handle>".
func ParseMailRetryActor(value string) (MailRetryActor, error) {
if len(value) > 128 || !mailRetryActorPattern.MatchString(value) {
return "", invalidDelivery("domain.ParseMailRetryActor", "actor must be operator:<handle> of at most 128 bytes in lowercase letters, digits, '.', '_', or '-'")
}
return MailRetryActor(value), nil
}