model

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Required     = "required"
	Invalid      = "invalid"
	IsNotInreger = "is_not_integer"
)
View Source
const DateLayout = "2006-01-02"

Variables

View Source
var (
	ErrNotFound  = NewError("operation.not_found")
	ErrBadNumber = NewError("query.bad_number")
	ErrBadVIN    = NewError("query.bad_vin")
	ErrBadCode   = NewError("query.bad_code")
)

Functions

func ErrorMessages added in v0.1.35

func ErrorMessages(prefix string, err error) map[string][]string

func ToSnakeCase added in v0.1.35

func ToSnakeCase(str string) string

func Validate added in v0.1.35

func Validate(v validation.Validatable, prefix string) error

Types

type Error

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

func NewError

func NewError(text string) Error

func (Error) Error

func (e Error) Error() string

type Registration

type Registration struct {
	Brand          *string  `json:"brand,omitempty"`
	Capacity       *int     `json:"capacity,omitempty"`
	Color          string   `json:"color"`
	FirstRegDate   *string  `json:"first_reg_date,omitempty"`
	Date           *string  `json:"date,omitempty"`
	Fuel           *string  `json:"fuel,omitempty"`
	Kind           *string  `json:"kind,omitempty"`
	Year           int      `json:"year"`
	Model          *string  `json:"model,omitempty"`
	DocumentNumber string   `json:"-"`
	DocumentSeries string   `json:"-"`
	Code           string   `json:"code"`
	Number         string   `json:"number"`
	NumSeating     *int     `json:"num_seating,omitempty"`
	NumStanding    *int     `json:"num_standing,omitempty"`
	OwnWeight      *float64 `json:"own_weight,omitempty"`
	RankCategory   *string  `json:"rank_category,omitempty"`
	TotalWeight    *float64 `json:"total_weight,omitempty"`
	VIN            *string  `json:"vin,omitempty"`
	IsActive       *bool    `json:"is_active,omitempty"`
}

func TestRegistration

func TestRegistration(t *testing.T) *Registration

TestRegistration returns example registration.

func (*Registration) Schema

func (r *Registration) Schema() *vehicle.Registration

type ValidationError

type ValidationError struct {
	Messages map[string][]string
}

func NewValidationError

func NewValidationError(messages map[string][]string) ValidationError

func (*ValidationError) Append

func (e *ValidationError) Append(field string, message ...string)

func (ValidationError) Error

func (e ValidationError) Error() string

func (ValidationError) WithPrefix

func (e ValidationError) WithPrefix(prefix string) ValidationError

Jump to

Keyboard shortcuts

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