Skip to content

Commit

Permalink
Add validation for start_time to resource_policy
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
chrisst authored and modular-magician committed Jan 8, 2020
1 parent 2da84c4 commit c23abb1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions google/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,16 @@ func StringNotInSlice(invalid []string, ignoreCase bool) schema.SchemaValidateFu
return
}
}

// Ensure that hourly timestamp strings "HH:MM" have the minutes zeroed out for hourly only inputs
func validateHourlyOnly(val interface{}, key string) (warns []string, errs []error) {
v := val.(string)
parts := strings.Split(v, ":")
if len(parts) != 2 {
errs = append(errs, fmt.Errorf("%q must be in the format HH:00, got: %s", key, v))
}
if parts[1] != "00" {
errs = append(errs, fmt.Errorf("%q does not allow minutes, it must be in the format HH:00, got: %s", key, v))
}
return
}

0 comments on commit c23abb1

Please sign in to comment.