validation

package
v0.0.0-...-d3458be Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: BSD-3-Clause Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidDigest

func IsValidDigest(hash string) bool

IsValidDigest returns true if the given string is a valid digest on the string level, i.e. it does not check whether we have actually seen the given hash but whether it complies with the format that we expect for a hash.

Types

type ExpirationMonitor

type ExpirationMonitor struct {
	// contains filtered or unexported fields
}

ExpirationMonitor provides a struct to perform expiration monitoring tasks.

func NewExpirationMonitor

func NewExpirationMonitor(dataManager data_manager.ExpiryDataManager) *ExpirationMonitor

New returns a new instance of the ExpirationMonitor.

func (*ExpirationMonitor) UpdateTriagedExpectationsExpiry

func (m *ExpirationMonitor) UpdateTriagedExpectationsExpiry(ctx context.Context) error

UpdateTriagedExpectationsExpiry retrieves positively triaged Expectations that are about to expire in a month and updates them to never expire.

Positively triaged expectations are used as the baseline to compare images and need to exist for as long as needed. While Expectations that get updated post checkin have their expiry auto updated, the ones that are triaged during the CL (i.e updated in ExpectationDeltas and then copied over to Expectations in gitilesFollower) get an expiry of 2 months (default on the Expectations table rows for ON CREATE operation). This function will capture those and update their expiry accordingly.

type Validation

type Validation []string

Validation is a container to collect error messages during validation of a input with multiple fields.

func (*Validation) Errors

func (v *Validation) Errors() error

Errors returns a concatenation of all error values accumulated in validation or nil if there were no errors.

func (*Validation) Float64FormValue

func (v *Validation) Float64FormValue(r *http.Request, name string, defaultVal float64) float64

Float64FormValue does the same as Float64Value but extracts the value from the request object.

func (*Validation) Float64Value

func (v *Validation) Float64Value(name string, strVal string, defaultVal float64) float64

Float64Value parses the value given in strVal and returns it. If strVal is empty the default value is returned.

func (*Validation) Int64FormValue

func (v *Validation) Int64FormValue(r *http.Request, name string, defaultVal int64) int64

Int64FormValue does the same as Int64Value but extracts the value from the request object.

func (*Validation) Int64SliceFormValue

func (v *Validation) Int64SliceFormValue(r *http.Request, name string, defaultVal []int64) []int64

Int64SliceFormValue does the same as Int64SliceValue but extracts the given name from the request.

func (*Validation) Int64SliceValue

func (v *Validation) Int64SliceValue(name string, strVal string, defaultVal []int64) []int64

Int64SliceValue parses a comma-separated list of int values and returns them.

func (*Validation) Int64Value

func (v *Validation) Int64Value(name string, strVal string, defaultVal int64) int64

Int64Value parses the value given in strVal and returns it. If strVal is empty the default value is returned.

func (*Validation) QueryFormValue

func (v *Validation) QueryFormValue(r *http.Request, name string) map[string][]string

QueryFormValue extracts a URL-encoded query from the form values and decodes it. If the named field was not available in the given request an empty paramtools.ParamSet is returned. If an error occurs it will be added to the error list of the validation object.

func (*Validation) StrFormValue

func (v *Validation) StrFormValue(r *http.Request, name string, val *string, options []string, defaultVal string)

StrFormValue does the same as StrValue but extracts the given name from the request via r.FormValue(..).

func (*Validation) StrValue

func (v *Validation) StrValue(name string, val *string, options []string, defaultVal string)

StrValue validates a string value against containment in a set of options. Argument:

name: name of the field being validated.
val: value to be validated.
options: list of options, one of which value can contain.
defaultVal: default value in case val is empty. Can be equal to "".

If there is a problem an error message will be added to the Validation object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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