package handlers

import (
	"errors"

	tzpkg "wucher/internal/shared/pkg/timezone"
	"wucher/internal/transport/http/jsonapi"
)

func timezoneValidationError(pointer string, err error) []jsonapi.ErrorObject {
	detail := "timezone must be a valid IANA timezone"
	if errors.Is(err, tzpkg.ErrEmpty) {
		detail = "timezone cannot be empty"
	}
	return []jsonapi.ErrorObject{{
		Status: "422",
		Title:  "Validation error",
		Detail: detail,
		Source: &jsonapi.ErrorSource{Pointer: pointer},
	}}
}
