Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2f64d4c

Browse files
authored
fix: show correct min and max values in validation errors (#122)
1 parent946db5a commit2f64d4c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

‎provider/parameter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,10 +438,10 @@ func (v *Validation) Valid(typ, value string) error {
438438
returnfmt.Errorf("value %q is not a number",value)
439439
}
440440
ifv.Min!=nil&&num<*v.Min {
441-
returnfmt.Errorf("value %d is less than the minimum %d",num,v.Min)
441+
returnfmt.Errorf("value %d is less than the minimum %d",num,*v.Min)
442442
}
443443
ifv.Max!=nil&&num>*v.Max {
444-
returnfmt.Errorf("value %d is more than the maximum %d",num,v.Max)
444+
returnfmt.Errorf("value %d is more than the maximum %d",num,*v.Max)
445445
}
446446
ifv.Monotonic!=""&&v.Monotonic!=ValidationMonotonicIncreasing&&v.Monotonic!=ValidationMonotonicDecreasing {
447447
returnfmt.Errorf("number monotonicity can be either %q or %q",ValidationMonotonicIncreasing,ValidationMonotonicDecreasing)

‎provider/parameter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,13 +499,13 @@ func TestValueValidatesType(t *testing.T) {
499499
Type:"number",
500500
Value:"0",
501501
Min:ptrNumber(1),
502-
Error:regexp.MustCompile("is less than the minimum"),
502+
Error:regexp.MustCompile("is less than the minimum 1"),
503503
}, {
504504
Name:"NumberAboveMax",
505505
Type:"number",
506506
Value:"2",
507507
Max:ptrNumber(1),
508-
Error:regexp.MustCompile("is more than the maximum"),
508+
Error:regexp.MustCompile("is more than the maximum 1"),
509509
}, {
510510
Name:"InvalidBool",
511511
Type:"bool",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp