From ae71478206c8197d05bac5dc438d2b1befa604d7 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 30 May 2023 13:20:52 +0200 Subject: [PATCH] fix: show correct min and max values in validation errors --- provider/parameter.go | 4 ++-- provider/parameter_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/provider/parameter.go b/provider/parameter.go index a9bbdc65..79ea2480 100644 --- a/provider/parameter.go +++ b/provider/parameter.go @@ -438,10 +438,10 @@ func (v *Validation) Valid(typ, value string) error { return fmt.Errorf("value %q is not a number", value) } if v.Min != nil && num < *v.Min { - return fmt.Errorf("value %d is less than the minimum %d", num, v.Min) + return fmt.Errorf("value %d is less than the minimum %d", num, *v.Min) } if v.Max != nil && num > *v.Max { - return fmt.Errorf("value %d is more than the maximum %d", num, v.Max) + return fmt.Errorf("value %d is more than the maximum %d", num, *v.Max) } if v.Monotonic != "" && v.Monotonic != ValidationMonotonicIncreasing && v.Monotonic != ValidationMonotonicDecreasing { return fmt.Errorf("number monotonicity can be either %q or %q", ValidationMonotonicIncreasing, ValidationMonotonicDecreasing) diff --git a/provider/parameter_test.go b/provider/parameter_test.go index 4b2fe9c9..945820a1 100644 --- a/provider/parameter_test.go +++ b/provider/parameter_test.go @@ -499,13 +499,13 @@ func TestValueValidatesType(t *testing.T) { Type: "number", Value: "0", Min: ptrNumber(1), - Error: regexp.MustCompile("is less than the minimum"), + Error: regexp.MustCompile("is less than the minimum 1"), }, { Name: "NumberAboveMax", Type: "number", Value: "2", Max: ptrNumber(1), - Error: regexp.MustCompile("is more than the maximum"), + Error: regexp.MustCompile("is more than the maximum 1"), }, { Name: "InvalidBool", Type: "bool", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy