15 lines
223 B
Go
15 lines
223 B
Go
|
package ui
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"regexp"
|
||
|
)
|
||
|
|
||
|
func ValidateString(s string) error {
|
||
|
validRegex := regexp.MustCompile(`^[a-zA-Z0-9_.]+$`)
|
||
|
if !validRegex.MatchString(s) {
|
||
|
return errors.New("invalid input")
|
||
|
}
|
||
|
return nil
|
||
|
}
|