(v interface{})
| 70 | } |
| 71 | |
| 72 | func (rv *RangeValidator) Validate(v interface{}) error { |
| 73 | f64 := v.(float64) |
| 74 | |
| 75 | if f64 < rv.min || f64 > rv.max { |
| 76 | var msg string |
| 77 | if math.Abs(rv.min-math.Floor(rv.min)) < math.SmallestNonzeroFloat64 && |
| 78 | math.Abs(rv.max-math.Floor(rv.max)) < math.SmallestNonzeroFloat64 { |
| 79 | |
| 80 | msg = fmt.Sprintf(tr("Please enter a number from %.f to %.f.", "walk"), |
| 81 | rv.min, rv.max) |
| 82 | } else { |
| 83 | msg = fmt.Sprintf(tr("Please enter a number from %s to %s.", "walk"), |
| 84 | FormatFloatGrouped(rv.min, 2), FormatFloatGrouped(rv.max, 2)) |
| 85 | } |
| 86 | |
| 87 | return NewValidationError(tr("Number out of allowed range", "walk"), msg) |
| 88 | } |
| 89 | |
| 90 | return nil |
| 91 | } |
| 92 | |
| 93 | type RegexpValidator struct { |
| 94 | re *regexp.Regexp |
nothing calls this directly
no test coverage detected