Multiple implementations of the same back-end application. The aim is to provide quick, side-by-side comparisons of different technologies (languages, frameworks, libraries) while preserving consistent business logic across all implementations.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
755 B

package dto
import (
"errors"
"net/url"
)
var (
ErrInvalidItemName = errors.New("item name cannot be empty")
ErrInvalidOrderURL = errors.New("invalid order URL format")
ErrInvalidExpirationDate = errors.New("invalid expiration date")
)
type CreateItemDTO struct {
Name string `json:"name" binding:"required"`
ExpirationDate JSONTime `json:"expirationDate" binding:"required"`
OrderURL string `json:"orderUrl" binding:"required"`
}
func (dto *CreateItemDTO) Validate() error {
if dto.Name == "" {
return ErrInvalidItemName
}
if _, err := url.ParseRequestURI(dto.OrderURL); err != nil {
return ErrInvalidOrderURL
}
if dto.ExpirationDate.Time.IsZero() {
return ErrInvalidExpirationDate
}
return nil
}