mirror of
https://github.com/koho/frpmgr.git
synced 2025-10-21 00:23:46 +08:00
* Add properties dialog * Resize window * Count TCP and UDP connections * Resize the first column * Fix lint error
35 lines
627 B
Go
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)
|
|
}
|