validation

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package validation contains functions for validating constraints are met for given strings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsName

func IsName(err Errors, name string)

IsName validates the name and adds to Errors if the name is invalid

func IsTimezone added in v1.0.0

func IsTimezone(str string) bool

IsTimezone returns true if the timezone is valid for the OIQ Collector

func WarningFormatFunc added in v1.1.0

func WarningFormatFunc(es []error) string

WarningFormatFunc is like the standard FormatFunc but labels issues as "warnings" instead of "errors".

Types

type Errors

type Errors interface {
	// Add adds an error to the set of errors accumulated by Errors. If err is nil, this does nothing.
	Add(err error)

	// Warn adds an error to a separate set of Errors that are only warnings. These warnings should not prevent validation
	// from passing, but should be presented to the user.
	Warn(err error)

	// Result returns an error containing all of the errors accumulated or nil if there were no errors
	Result() error

	// Warnings returns a string representing all of the warning messages accumulated or "" if there were no warnings
	Warnings() string
}

Errors provides an ErrorReporter to accumulate errors.

func NewErrors

func NewErrors() Errors

NewErrors creates new validation errors and returns the reporter as a convenience

Jump to

Keyboard shortcuts

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