File size: 776 Bytes
6380833
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package timeutil

import (
	"fmt"
	"slices"
)

type Boundary string

const (
	// Exclusive means the specified boundary time is excluded from the interval.
	// For example, for the range (2025-01-01T00:00:00Z, 2025-01-02T00:00:00Z),
	// the instant 2025-01-01T00:00:00Z is not considered part of the interval.
	Exclusive Boundary = "exclusive"

	// Inclusive means the specified boundary time is included in the interval.
	// For example, for the range [2025-01-01T00:00:00Z, 2025-01-02T00:00:00Z],
	// the instant 2025-01-01T00:00:00Z is considered part of the interval.
	Inclusive Boundary = "inclusive"
)

func (b Boundary) Validate() error {
	if !slices.Contains([]Boundary{Exclusive, Inclusive}, b) {
		return fmt.Errorf("invalid boundary type: %s", b)
	}

	return nil
}