Semaphore/db/Option.go

25 lines
336 B
Go
Raw Normal View History

2024-03-10 18:55:42 +01:00
package db
import (
"fmt"
"regexp"
)
2024-03-10 18:55:42 +01:00
type Option struct {
Key string `db:"key" json:"key"`
Value string `db:"value" json:"value"`
}
func ValidateOptionKey(key string) error {
2024-07-09 12:37:47 +02:00
m, err := regexp.Match(`^[\w.]+$`, []byte(key))
if err != nil {
return err
}
if !m {
return fmt.Errorf("invalid key format")
}
return nil
}