Documentation
¶
Index ¶
- Constants
- type ConfigStruct
- type MessageBrokerString
- type PortString
- type SimpleConfigYAML
- type URLDataBase
- type URLString
- type ValidationResult
- func (v *ValidationResult) AddError(err error)
- func (v *ValidationResult) Detail() map[string][]error
- func (v *ValidationResult) ErrorHandler(err error)
- func (v *ValidationResult) GetField() string
- func (v *ValidationResult) IsValid() bool
- func (v *ValidationResult) Print()
- func (v *ValidationResult) SetField(field string)
- type Validator
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 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
Click to show internal directories.
Click to hide internal directories.