mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-11-23 12:30:41 +01:00
25 lines
336 B
Go
25 lines
336 B
Go
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
type Option struct {
|
|
Key string `db:"key" json:"key"`
|
|
Value string `db:"value" json:"value"`
|
|
}
|
|
|
|
func ValidateOptionKey(key string) error {
|
|
m, err := regexp.Match(`^[\w.]+$`, []byte(key))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !m {
|
|
return fmt.Errorf("invalid key format")
|
|
}
|
|
|
|
return nil
|
|
}
|