Files
frpmgr/pkg/validators/regexp.go
Gerhard Tan 325a2e6a5e Add properties dialog (#250)
* Add properties dialog

* Resize window

* Count TCP and UDP connections

* Resize the first column

* Fix lint error
2025-06-25 10:03:22 +08:00

35 lines
627 B
Go

package validators
import (
"github.com/lxn/walk"
)
type RegexpValidator struct {
*walk.RegexpValidator
}
func NewRegexpValidator(pattern string) (*RegexpValidator, error) {
re, err := walk.NewRegexpValidator(pattern)
if err != nil {
return nil, err
}
return &RegexpValidator{re}, nil
}
func (rv *RegexpValidator) Validate(v interface{}) error {
err := rv.RegexpValidator.Validate(v)
if str, ok := v.(string); ok && str == "" && err != nil {
return errSilent
}
return err
}
type Regexp struct {
Pattern string
}
func (re Regexp) Create() (walk.Validator, error) {
return NewRegexpValidator(re.Pattern)
}