Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrProductNotFound = fmt.Errorf("Product not found")
Functions ¶
func DeleteProduct ¶
DeleteProduct deletes a product from the database
func FromJSON ¶
FromJSON deserializes the object from JSON string in an io.Reader to the given interface
func UpdateProduct ¶
UpdateProduct replaces a product in the database with the given item. If a product with the given id does not exist in the database this function returns a ProductNotFound error
Types ¶
type Product ¶
type Product struct { // the id for this model // // required: true // min: 1 ID int `json:"id"` Name string `json:"name" validate:"required"` Description string `json:"description"` Price float32 `json:"price" validate:"gt=0"` SKU string `json:"sku,omitempty" validate:"required,sku"` CreatedOn string `json:"-"` UpdatedOn string `json:"-"` DeletedOn string `json:"-"` }
Product defines the structure for an API product swagger: model
func GetProductByID ¶
GetProductByID returns a single product which matches the 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
}
Validation contains
func (*Validation) Validate ¶
func (v *Validation) Validate(i interface{}) ValidationErrors
type ValidationError ¶
type ValidationError struct {
validator.FieldError
}
ValidationError wraps the validators FieldError so we do not expose this to out code
func (ValidationError) Error ¶
func (v ValidationError) Error() string
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors is a collection of ValidationError
func (ValidationErrors) Errors ¶
func (v ValidationErrors) Errors() []string
Errors converts the slice into a string slice