validators

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package validators helper functions for validate params

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metric

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

Metric help to validate metrics

func NewMetric

func NewMetric(metrics map[string]string) *Metric

NewMetric construct a new metric

func (*Metric) GetMetricValue

func (p *Metric) GetMetricValue(metric string) (value string, exist bool)

GetMetricValue get metric value

func (*Metric) ValidateFloat

func (p *Metric) ValidateFloat(base *field.Path, metric string, min, max *float64) (errs field.ErrorList)

ValidateFloat help to validate float metrics

func (*Metric) ValidateInt

func (p *Metric) ValidateInt(base *field.Path, metric string, min, max *int) (errs field.ErrorList)

ValidateInt help to validate int metrics

func (*Metric) ValidateStringEnums

func (p *Metric) ValidateStringEnums(base *field.Path, metric string, enums ...string) (errs field.ErrorList)

ValidateStringEnums help to validate that it is within the scope of the enumeration

type URL

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

URL help to validate url

func NewURL

func NewURL() *URL

NewURL construct a new metric

func (*URL) SetErrMsg

func (p *URL) SetErrMsg(msg string) *URL

SetErrMsg customize error message

func (*URL) SetValidate

func (p *URL) SetValidate(f ValidateURLFunc) *URL

SetValidate customize validate function

func (*URL) Validate

func (p *URL) Validate(path *field.Path, urls ...string) (errs field.ErrorList)

Validate Support to verify multiple urls at the same time

type ValidateURLFunc

type ValidateURLFunc func(url *url.URL) (ok bool, errMsg string)

ValidateURLFunc function to validate url

Jump to

Keyboard shortcuts

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