diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-09-16 14:29:26 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-09-30 10:00:18 +0000 |
| commit | 179f40292f64debb6b3ea2fe5e950f62f5a05a18 (patch) | |
| tree | 664326084a8dee3bbe8847cf8196fd0b9417dee4 /pkg/validator/validator.go | |
| parent | ba29ff75d05fca62258d71ffc063e70f0d7b8b09 (diff) | |
pkg/validator: target value is not empty by default
The consistency make the code more predictable.
We want all the values to be non-empty.
If "empty" is an option - use validator.AnyOk(validator.EmptyStr(target), otherCheck(target)).
Diffstat (limited to 'pkg/validator/validator.go')
| -rw-r--r-- | pkg/validator/validator.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/validator/validator.go b/pkg/validator/validator.go index 723cf2384..d4192f7b6 100644 --- a/pkg/validator/validator.go +++ b/pkg/validator/validator.go @@ -66,6 +66,9 @@ type strValidationFunc func(string, ...string) Result func makeStrReFunc(errStr, reStr string) strValidationFunc { matchRe := regexp.MustCompile(reStr) return func(s string, objName ...string) Result { + if s == "" { + return Result{false, wrapError(errStr + ": can't be empty")} + } if !matchRe.MatchString(s) { return Result{false, wrapError(errStr, objName...)} } |
