This commit is contained in:
2026-08-21 17:52:28 +04:00
parent d7b8f08b4d
commit eb195dd992
116 changed files with 2719 additions and 1973 deletions

View File

@@ -488,3 +488,9 @@ func sepDescriptionValidator(fe validator.FieldLevel) bool {
ok, _ := regexp.MatchString(`^[a-zA-Zа-яА-ЯёЁ0-9_.\[\]()\-]*$`, fe.Field().String())
return ok
}
func watchdogActionValidator(fe validator.FieldLevel) bool {
fieldValue := fe.Field().String()
return IsInSlice(fieldValue, watchdogActionVaues)
}

View File

@@ -15,6 +15,10 @@ func errorMessage(fe validator.FieldError) string {
// Common Validators
case "required":
return fmt.Sprintf("%s %s is required", prefix, fe.Field())
case "required_without_all":
return fmt.Sprintf("%s at least one of the following must be specified: %s",
prefix,
joinValues(append([]string{fe.Field()}, strings.Fields(fe.Param())...)))
case "gt":
return fmt.Sprintf("%s %s can't be less or equal to zero", prefix, fe.Field())
case "min":
@@ -25,6 +29,8 @@ func errorMessage(fe validator.FieldError) string {
return fmt.Sprintf("%s %s: unexpected URL format", prefix, fe.Field())
case "email":
return fmt.Sprintf("%s %s: unexpected E-Mail format", prefix, fe.Field())
case "mac":
return fmt.Sprintf("%s %s: unexpected MAC address format", prefix, fe.Field())
case "isBool":
return fmt.Sprintf("%s %s: must be bool type", prefix, fe.Field())
case "isString":

View File

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

View File

@@ -47,7 +47,7 @@ var (
vmActionValues = []string{"stop", "move"}
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk"}
computeFeaturesValues = []string{"hugepages", "numa", "cpupin", "vfnic", "dpdk", "changemac", "trunk", "vgpu", "pcidevice"}
networkInterfaceNamingValues = []string{"eth", "ens"}
@@ -80,6 +80,8 @@ var (
ipTypeValues = []string{"v4, v6"}
sepTechStatusValues = []string{"ENABLED", "DISABLED"}
watchdogActionVaues = []string{"reset", "shutdown", "poweroff", "pause", "none"}
)
const (