Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrProductNotFound = fmt.Errorf("Product not found")
Functions ¶
func DeleteProduct ¶
func FromJSON ¶
FromJSON deserializes the object from JSON string in an io.Reader to the given interface
func UpdateProduct ¶
Types ¶
type Product ¶
type Product struct { // the id for the product // // required: false // min: 1 ID int `json:"id"` // Unique identifier for the product // the name for this poduct // // required: true // max length: 255 Name string `json:"name" validate:"required"` // the description for this poduct // // required: false // max length: 10000 Description string `json:"description"` // the price for the product // // required: true // min: 0.01 Price float32 `json:"price" validate:"required,gt=0"` // the SKU for the product // // required: true // pattern: [a-z]+-[a-z]+-[a-z]+ SKU string `json:"sku" validate:"sku"` }
Product defines the structure for an API product swagger: model
func GetProductByID ¶
GetProductByID is a func that returns the single product by id from the database If a product is not found this function returns a ProductNotFound error
type Validation ¶
type Validation struct {
// contains filtered or unexported fields
}
func (*Validation) Validate ¶
func (v *Validation) Validate(i interface{}) ValidationErrors
validate finc
type ValidationError ¶
type ValidationError struct {
validator.FieldError
}
this wraps all the validators field errors
func (ValidationError) Error ¶
func (v ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
collection of ValidationError
func (ValidationErrors) Errors ¶
func (v ValidationErrors) Errors() []string
Errors converts the slice into a string slice
Click to show internal directories.
Click to hide internal directories.