summaryrefslogtreecommitdiff
path: root/model/validation.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/validation.go')
-rw-r--r--model/validation.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/model/validation.go b/model/validation.go
index d49141d..ac38777 100644
--- a/model/validation.go
+++ b/model/validation.go
@@ -26,3 +26,16 @@ func isPositiveOrZeroInt(s string) error {
return nil
}
+
+func isPositiveOrZeroFloat(s string) error {
+ f, err := strconv.ParseFloat(s, 32)
+ if err != nil {
+ return fmt.Errorf("'%s' cannot be casted to floating point number", s)
+ }
+
+ if f < 0 {
+ return fmt.Errorf("'%s' is negative", s)
+ }
+
+ return nil
+}