validate

package
v1.29.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2024 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BillingRef

func BillingRef(billingRef string) error

BillingRef validates a given billing reference

func DefaultResponseErrorHandler

func DefaultResponseErrorHandler(resp *http.Response) error

DefaultResponseErrorHandler is the default error handler used to check if a giving STACKIT API response returned an error

func Duration

func Duration(s string) (time.Duration, error)

Duration validates that a given string can be parsed as duration i.e. 5m, 60s, 1h

func ErrorIsOneOf added in v1.19.0

func ErrorIsOneOf(err error, msgs ...string) bool

ErrorIsOneOf checks checks if a given error message has one of the provided sub strings

func Field added in v1.19.0

func Field(resp interface{}, field string) error

Field validates that given field in the response object is set (not nil)

func Fields added in v1.19.0

func Fields(resp interface{}, fields ...string) error

Fields validates that given fields in the response object are set (not nil)

func ISO8601

func ISO8601(t string) error

ISO8601 Validates that given time is formatted as ISO 8601

func NameServer added in v1.29.2

func NameServer(name string) error

NameServer validates a given server name

func NetworkID added in v1.29.2

func NetworkID(id string) error

func NetworkName added in v1.29.2

func NetworkName(name string) error

NetworkName validates a given network name

func Prefix added in v1.29.2

func Prefix(pr string) error

Prefix validates a given prefix

func PrefixLengthV4 added in v1.29.2

func PrefixLengthV4(prefix int64) error

PrefixLengthV4 validates a given server name.

func ProjectID

func ProjectID(projectID string) error

ProjectID validates a given project ID

func ProjectName

func ProjectName(name string) error

ProjectName validates a given project name

func PublicIP added in v1.29.2

func PublicIP(ip string) error

PublicIP validates a given ID address

func RFC3339

func RFC3339(t string) error

RFC3339 Validates that given time is formatted as RFC3339

func Response added in v1.9.0

func Response(resp interface{}, requestError error, checkNullFields ...string) error

Response validates a response interface and error if requestError has an error, it is returned if resp.Error is defined and not nil, it is returned if one of the field namess provided in []checkNullFields are nil, an error is returned

func ResponseObject added in v1.19.0

func ResponseObject(resp interface{}) error

ResponseObject validates the response response and checks if it has an Error field that's set

func SemVer

func SemVer(version string) error

SemVer validates a given version

func StatusEquals added in v1.17.1

func StatusEquals(a ResponseInterface, statusCode ...int) bool

StatusEquals returns true if interface.StatusCode() equals a given http code if more than one status code is provided, the function will return true if one of them matches

func UUID

func UUID(id string) error

UUID validates a given UUID

Types

type ResponseInterface added in v1.16.0

type ResponseInterface interface {
	StatusCode() int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL