37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
package calendar
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/ultisuite/ulti-backend/internal/api/apivalidate"
|
|
"github.com/ultisuite/ulti-backend/internal/nextcloud"
|
|
)
|
|
|
|
const maxRequestBody = 256 << 10
|
|
|
|
func validateCreateEvent(event *nextcloud.Event) *apivalidate.ValidationError {
|
|
var details []apivalidate.FieldDetail
|
|
if strings.TrimSpace(event.Summary) == "" {
|
|
details = append(details, apivalidate.FieldDetail{Field: "summary", Message: "required"})
|
|
}
|
|
if strings.TrimSpace(event.Start) == "" {
|
|
details = append(details, apivalidate.FieldDetail{Field: "start", Message: "required"})
|
|
}
|
|
if strings.TrimSpace(event.End) == "" {
|
|
details = append(details, apivalidate.FieldDetail{Field: "end", Message: "required"})
|
|
}
|
|
if len(details) == 0 {
|
|
return nil
|
|
}
|
|
return apivalidate.NewValidationError(details...)
|
|
}
|
|
|
|
func validateDeletePath(path string) *apivalidate.ValidationError {
|
|
if strings.TrimSpace(path) == "" {
|
|
return apivalidate.NewValidationError(apivalidate.FieldDetail{
|
|
Field: "path", Message: "required",
|
|
})
|
|
}
|
|
return nil
|
|
}
|