go-autorest: github.com/Azure/go-autorest/autorest/validation Index | Files

package validation

import "github.com/Azure/go-autorest/autorest/validation"

Package validation provides methods for validating parameter value using reflection.

Index

Package Files

error.go validation.go

Constants

const (
    Empty            = "Empty"
    Null             = "Null"
    ReadOnly         = "ReadOnly"
    Pattern          = "Pattern"
    MaxLength        = "MaxLength"
    MinLength        = "MinLength"
    MaxItems         = "MaxItems"
    MinItems         = "MinItems"
    MultipleOf       = "MultipleOf"
    UniqueItems      = "UniqueItems"
    InclusiveMaximum = "InclusiveMaximum"
    ExclusiveMaximum = "ExclusiveMaximum"
    ExclusiveMinimum = "ExclusiveMinimum"
    InclusiveMinimum = "InclusiveMinimum"
)

Constraint list

func Validate Uses

func Validate(m []Validation) error

Validate method validates constraints on parameter passed in validation array.

type Constraint Uses

type Constraint struct {

    // Target field name for validation.
    Target string

    // Constraint name e.g. minLength, MaxLength, Pattern, etc.
    Name string

    // Rule for constraint e.g. greater than 10, less than 5 etc.
    Rule interface{}

    // Chain Validations for struct type
    Chain []Constraint
}

Constraint stores constraint name, target field name Rule and chain validations.

type Error Uses

type Error struct {
    // PackageType is the package type of the object emitting the error. For types, the value
    // matches that produced the the '%T' format specifier of the fmt package. For other elements,
    // such as functions, it is just the package name (e.g., "autorest").
    PackageType string

    // Method is the name of the method raising the error.
    Method string

    // Message is the error message.
    Message string
}

Error is the type that's returned when the validation of an APIs arguments constraints fails.

func NewError Uses

func NewError(packageType string, method string, message string, args ...interface{}) Error

NewError creates a new Error object with the specified parameters. message is treated as a format string to which the optional args apply.

func (Error) Error Uses

func (e Error) Error() string

Error returns a string containing the details of the validation failure.

type Validation Uses

type Validation struct {
    TargetValue interface{}
    Constraints []Constraint
}

Validation stores parameter-wise validation.

Package validation imports 4 packages (graph) and is imported by 679 packages. Updated 2019-04-22. Refresh now. Tools for package owners.