You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
465 B
18 lines
465 B
package golang |
|
|
|
const durationTpl = `{{ $f := .Field }}{{ $r := .Rules }} |
|
{{ template "required" . }} |
|
|
|
{{ if or $r.In $r.NotIn $r.Lt $r.Lte $r.Gt $r.Gte $r.Const }} |
|
if d := {{ accessor . }}; d != nil { |
|
dur, err := d.AsDuration(), d.CheckValid() |
|
if err != nil { |
|
err = {{ errCause . "err" "value is not a valid duration" }} |
|
if !all { return err } |
|
errors = append(errors, err) |
|
} else { |
|
{{ template "durationcmp" . }} |
|
} |
|
} |
|
{{ end }} |
|
`
|
|
|