feat: command validation

This commit is contained in:
IliaDenisov
2026-02-10 18:31:53 +03:00
parent b5400bd61e
commit 6c8384ce7a
6 changed files with 178 additions and 30 deletions
+24
View File
@@ -15,3 +15,27 @@ var notBlankStringValidator validator.Func = func(fl validator.FieldLevel) bool
}
return true
}
var armamentWithWeaponsValidator validator.Func = func(fl validator.FieldLevel) bool {
var v, compareTo float64
f := fl.Parent().FieldByName(fl.Param())
if f.CanFloat() {
compareTo = f.Float()
} else if f.CanInt() {
compareTo = float64(f.Int())
} else {
return false
}
if fl.Field().CanFloat() {
v = fl.Field().Float()
} else if fl.Field().CanInt() {
v = float64(fl.Field().Int())
} else {
return false
}
return (v == 0 && compareTo == 0) || (v >= 1 && compareTo >= 1)
}