This commit is contained in:
dayterr
2025-12-23 17:49:46 +03:00
parent aac7108d8a
commit a59feae2f2
31 changed files with 133 additions and 69 deletions

View File

@@ -471,3 +471,10 @@ func addressPoolNetTypeValidator(fe validator.FieldLevel) bool {
return IsInSlice(fieldValue, addressPoolNetTypeValues)
}
// sepTechStatusValidator is used to validate SepTechStatus fields
func sepTechStatusValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, sepTechStatusValues)
}

View File

@@ -366,6 +366,12 @@ func errorMessage(fe validator.FieldError) string {
prefix,
fe.Field(),
joinValues(ipTypeValues))
case "sepTechStatus":
return fmt.Sprintf("%s %s must be one of the following: %s",
prefix,
fe.Field(),
joinValues(sepTechStatusValues))
}
return fe.Error()

View File

@@ -311,5 +311,10 @@ func registerAllValidators(validate *validator.Validate) error {
return err
}
err = validate.RegisterValidation("sepTechStatus", sepTechStatusValidator)
if err != nil {
return err
}
return nil
}

View File

@@ -81,6 +81,8 @@ var (
addressPoolNetTypeValues = []string{"IPv4", "IPv6", "MAC"}
ipTypeValues = []string{"v4, v6"}
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
)
const (