18 lines
597 B
Go
18 lines
597 B
Go
package meshmoduleassignerclient
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
var proposalIDOK = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{2,62}$`)
|
|
|
|
// CheckProposalID refuses an id that is no proposal's: lower-case letters, digits and dashes, 3 to 63 of them, so it is one
|
|
// key token. The holder writes proposals under it, and the keys of the asks about a proposal (`placement.<id>`) carry it.
|
|
func CheckProposalID(id string) error {
|
|
if !proposalIDOK.MatchString(id) {
|
|
return fmt.Errorf("mesh-module-assigner: %q is no proposal id (lower-case letters, digits and dashes, one key token)", id)
|
|
}
|
|
return nil
|
|
}
|