This commit is contained in:
2023-04-20 11:17:35 +03:00
parent 84b64b7d80
commit 7d6cda7119
40 changed files with 1337 additions and 126 deletions

View File

@@ -1,6 +1,9 @@
package validators
import "github.com/go-playground/validator/v10"
import (
"github.com/go-playground/validator/v10"
"regexp"
)
// protoValidator is used to validate Proto fields.
func protoValidator(fe validator.FieldLevel) bool {
@@ -203,3 +206,12 @@ func sepFieldTypeValidator(fe validator.FieldLevel) bool {
return StringInSlice(fieldValue, sepFieldTypeValues)
}
// hwPathValidator is used to validate HWPath field.
func hwPathValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
ok, _ := regexp.MatchString(`^\b[0-9a-f]{4}:[0-9a-fA-F]{2}:[0-9a-fA-F]{2}.\d{1}$`, fieldValue)
return ok
}