models

package
v0.0.0-...-7b38f86 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	MinLengthName = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigStruct

type ConfigStruct struct {
	Port        string `yaml:"port" json:"port"`
	DBUrl       string `yaml:"db_url" json:"db_url"`
	JaegerURL   string `yaml:"jaeger_url" json:"jaeger_url"`
	SentryURL   string `yaml:"sentry_url" json:"sentry_url"`
	KafkaBroker string `yaml:"kafka_broker" json:"kafka_broker"`
	AppID       string `yaml:"some_app_id" json:"some_app_id"`
	AppKey      string `yaml:"some_app_key" json:"some_app_key"`
}

Структура для файла конфигруций. Валидация реализована через пакет net/url

func (*ConfigStruct) GetValidationResult

func (c *ConfigStruct) GetValidationResult() *ValidationResult

Метод валидации полей структуры конфига

type MessageBrokerString

type MessageBrokerString string

type PortString

type PortString string

func (*PortString) IsValid

func (p *PortString) IsValid() bool

type SimpleConfigYAML

type SimpleConfigYAML struct {
	Port        PortString          `yaml:"port" json:"port"`
	DBUrl       URLDataBase         `yaml:"db_url" json:"db_url"`
	JaegerURL   URLString           `yaml:"jaeger_url" json:"jaeger_url"`
	SentryURL   URLString           `yaml:"sentry_url" json:"sentry_url"`
	KafkaBroker MessageBrokerString `yaml:"kafka_broker" json:"kafka_broker"`
	AppID       string              `yaml:"some_app_id" json:"some_app_id"`
	AppKey      string              `yaml:"some_app_key" json:"some_app_key"`
}

Структура для конфигруционного файла в YAML-формате. Валидация через резулярные выражения

type URLDataBase

type URLDataBase string

func (*URLDataBase) IsValid

func (u *URLDataBase) IsValid() bool

type URLString

type URLString string

func (*URLString) IsValid

func (u *URLString) IsValid() bool

type ValidationResult

type ValidationResult struct {
	Errors map[string][]error
	// contains filtered or unexported fields
}

func (*ValidationResult) AddError

func (v *ValidationResult) AddError(err error)

func (*ValidationResult) Detail

func (v *ValidationResult) Detail() map[string][]error

func (*ValidationResult) ErrorHandler

func (v *ValidationResult) ErrorHandler(err error)

func (*ValidationResult) GetField

func (v *ValidationResult) GetField() string
Example
vr := new(ValidationResult)
fieldName := "fieldOne"
vr.field = fieldName
fmt.Println(vr.GetField())
Output:

fieldOne

func (*ValidationResult) IsValid

func (v *ValidationResult) IsValid() bool

func (*ValidationResult) Print

func (v *ValidationResult) Print()

func (*ValidationResult) SetField

func (v *ValidationResult) SetField(field string)
Example
vr := new(ValidationResult)
fieldName := "fieldOne"
vr.SetField(fieldName)
fmt.Println(vr.field)
Output:

fieldOne

type Validator

type Validator interface {
	IsValid() bool
}

Jump to

Keyboard shortcuts

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