Validate reports whether the task-query filters are internally consistent.
(path string)
| 937 | |
| 938 | // Validate reports whether the task-query filters are internally consistent. |
| 939 | func (q Query) Validate(path string) error { |
| 940 | if q.Scope.Normalize() != "" { |
| 941 | if err := ValidateScopeBinding(q.Scope, q.WorkspaceID, path, "workspace_id"); err != nil { |
| 942 | return err |
| 943 | } |
| 944 | } |
| 945 | if q.Status.Normalize() != "" { |
| 946 | if err := q.Status.Validate(nestedPath(path, "status")); err != nil { |
| 947 | return err |
| 948 | } |
| 949 | } |
| 950 | if q.Priority.Normalize() != "" { |
| 951 | if err := q.Priority.Validate(nestedPath(path, "priority")); err != nil { |
| 952 | return err |
| 953 | } |
| 954 | } |
| 955 | if q.ApprovalState.Normalize() != "" { |
| 956 | if err := q.ApprovalState.Validate(nestedPath(path, "approval_state")); err != nil { |
| 957 | return err |
| 958 | } |
| 959 | } |
| 960 | if q.OwnerKind.Normalize() != "" { |
| 961 | if err := q.OwnerKind.Validate(nestedPath(path, "owner_kind")); err != nil { |
| 962 | return err |
| 963 | } |
| 964 | } |
| 965 | if q.CreatedByKind.Normalize() != "" { |
| 966 | if err := q.CreatedByKind.Validate(nestedPath(path, "created_by_kind")); err != nil { |
| 967 | return err |
| 968 | } |
| 969 | } |
| 970 | if q.Limit < 0 { |
| 971 | return fmt.Errorf("%w: %s must be zero or positive: %d", ErrValidation, nestedPath(path, "limit"), q.Limit) |
| 972 | } |
| 973 | return nil |
| 974 | } |
| 975 | |
| 976 | // Validate reports whether the scheduler backlog filters are internally consistent. |
| 977 | func (q SchedulerBacklogQuery) Validate(path string) error { |
no test coverage detected