(sourceParam string, dest *time.Duration, valueMustExist bool)
| 1186 | } |
| 1187 | |
| 1188 | func (b *ValueBinder) duration(sourceParam string, dest *time.Duration, valueMustExist bool) *ValueBinder { |
| 1189 | if b.failFast && b.errors != nil { |
| 1190 | return b |
| 1191 | } |
| 1192 | |
| 1193 | value := b.ValueFunc(sourceParam) |
| 1194 | if value == "" { |
| 1195 | if valueMustExist { |
| 1196 | b.setError(b.ErrorFunc(sourceParam, []string{value}, "required field value is empty", nil)) |
| 1197 | } |
| 1198 | return b |
| 1199 | } |
| 1200 | t, err := time.ParseDuration(value) |
| 1201 | if err != nil { |
| 1202 | b.setError(b.ErrorFunc(sourceParam, []string{value}, "failed to bind field value to Duration", err)) |
| 1203 | return b |
| 1204 | } |
| 1205 | *dest = t |
| 1206 | return b |
| 1207 | } |
| 1208 | |
| 1209 | // Durations binds parameter values to slice of time.Duration variables |
| 1210 | func (b *ValueBinder) Durations(sourceParam string, dest *[]time.Duration) *ValueBinder { |
no test coverage detected