handlers

package
v0.0.0-...-c447797 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPoints

func GetPoints(c *fiber.Ctx) error

func HandleError

func HandleError(e error, c *fiber.Ctx, status int) error

func Home

func Home(c *fiber.Ctx) error

func InitValidators

func InitValidators()

func ParseFloat

func ParseFloat(s any) float64

func ProcessReceipt

func ProcessReceipt(c *fiber.Ctx) error

func ValidateInput

func ValidateInput(data interface{}) *fiber.Error

func ValidatePurchaseDate

func ValidatePurchaseDate(fl validator.FieldLevel) bool

func ValidatePurchaseTime

func ValidatePurchaseTime(fl validator.FieldLevel) bool

Types

type Error

type Error struct {
	Message string `json:"message"`
	Status  int    `json:"status"`
}

type ErrorResponse

type ErrorResponse struct {
	Error       bool
	FailedField string
	Tag         string
	Value       interface{}
}

type Item

type Item struct {
	ShortDescription string
	Price            float64
}

Used after validation

type ItemRaw

type ItemRaw struct {
	ShortDescription string `json:"shortDescription" validate:"required"`
	Price            any    `json:"price" validate:"required,numeric"`
}

type Receipt

type Receipt struct {
	Retailer     string
	PurchaseDate string
	PurchaseTime string
	Total        float64
	Items        []Item
	Points       int
}

Used after validation

type ReceiptID

type ReceiptID struct {
	ID string `json:"id"`
}

type ReceiptPoints

type ReceiptPoints struct {
	Points int `json:"points"`
}

type ReceiptRaw

type ReceiptRaw struct {
	Retailer     string    `json:"retailer" validate:"required"`
	PurchaseDate string    `json:"purchaseDate" validate:"required,purchaseDate"`
	PurchaseTime string    `json:"purchaseTime" validate:"required,purchaseTime"`
	Total        any       `json:"total" validate:"required,numeric"`
	Items        []ItemRaw `json:"items" validate:"required,min=1"`
}

type XValidator

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

func (XValidator) Validate

func (v XValidator) Validate(data interface{}) []ErrorResponse

Jump to

Keyboard shortcuts

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