A community based topic aggregation platform built on atproto
1package adminreports
2
3import "errors"
4
5var (
6 // ErrInvalidReason indicates the report reason is not a valid category
7 ErrInvalidReason = errors.New("invalid report reason: must be one of csam, doxing, harassment, spam, illegal, other")
8
9 // ErrInvalidStatus indicates the report status is not a valid value
10 ErrInvalidStatus = errors.New("invalid report status: must be one of open, reviewing, resolved, dismissed")
11
12 // ErrInvalidTarget indicates the target URI is malformed or invalid
13 ErrInvalidTarget = errors.New("invalid target URI: must be a valid AT Protocol URI starting with at://")
14
15 // ErrExplanationTooLong indicates the explanation exceeds the maximum length
16 ErrExplanationTooLong = errors.New("explanation exceeds maximum length of 1000 characters")
17
18 // ErrReporterRequired indicates the reporter DID was not provided
19 ErrReporterRequired = errors.New("reporter DID is required")
20
21 // ErrReportNotFound indicates the requested report does not exist
22 ErrReportNotFound = errors.New("report not found")
23
24 // ErrInvalidTargetType indicates the target type is not a valid value
25 ErrInvalidTargetType = errors.New("invalid target type: must be one of post, comment")
26)
27
28// IsValidationError checks if an error is a validation error
29func IsValidationError(err error) bool {
30 return errors.Is(err, ErrInvalidReason) ||
31 errors.Is(err, ErrInvalidStatus) ||
32 errors.Is(err, ErrInvalidTarget) ||
33 errors.Is(err, ErrExplanationTooLong) ||
34 errors.Is(err, ErrReporterRequired) ||
35 errors.Is(err, ErrInvalidTargetType)
36}
37
38// IsNotFound checks if an error is a "not found" error
39func IsNotFound(err error) bool {
40 return errors.Is(err, ErrReportNotFound)
41}