From 62590c604c7f393380e90c041bcac1e3f3792054 Mon Sep 17 00:00:00 2001 From: Dominik Rastawicki Date: Thu, 9 Sep 2021 18:56:44 +0800 Subject: [PATCH] Add regex validation to start_time_of_day --- pagerduty/resource_pagerduty_schedule.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pagerduty/resource_pagerduty_schedule.go b/pagerduty/resource_pagerduty_schedule.go index 33fff149a..98aa8b111 100644 --- a/pagerduty/resource_pagerduty_schedule.go +++ b/pagerduty/resource_pagerduty_schedule.go @@ -3,10 +3,12 @@ package pagerduty import ( "fmt" "log" + "regexp" "time" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/heimweh/go-pagerduty/pagerduty" ) @@ -103,8 +105,9 @@ func resourcePagerDutySchedule() *schema.Resource { }, "start_time_of_day": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringMatch(regexp.MustCompile(`([0-1][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]`), "must be of 00:00:00 format"), }, "start_day_of_week": {