MCPcopy Index your code
hub / github.com/perkeep/perkeep / checkValid

Method checkValid

pkg/search/query.go:236–261  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

234}
235
236func (q *SearchQuery) checkValid(ctx context.Context) (sq *SearchQuery, err error) {
237 if q.Sort >= maxSortType || q.Sort < 0 {
238 return nil, errors.New("invalid sort type")
239 }
240 if q.Continue != "" && q.Around.Valid() {
241 return nil, errors.New("Continue and Around parameters are mutually exclusive")
242 }
243 if q.Sort == MapSort && (q.Continue != "" || q.Around.Valid()) {
244 return nil, errors.New("Continue or Around parameters are not available with MapSort")
245 }
246 if q.Constraint != nil && q.Expression != "" {
247 return nil, errors.New("Constraint and Expression are mutually exclusive in a search query")
248 }
249 if q.Constraint != nil {
250 return sq, q.Constraint.checkValid()
251 }
252 expr := q.Expression
253 sq, err = parseExpression(ctx, expr)
254 if err != nil {
255 return nil, fmt.Errorf("Error parsing search expression %q: %v", expr, err)
256 }
257 if err := sq.Constraint.checkValid(); err != nil {
258 return nil, fmt.Errorf("Internal error: parseExpression(%q) returned invalid constraint: %v", expr, err)
259 }
260 return sq, nil
261}
262
263// SearchResult is the result of the Search method for a given SearchQuery.
264type SearchResult struct {

Callers

nothing calls this directly

Calls 3

parseExpressionFunction · 0.85
checkValidMethod · 0.65
ValidMethod · 0.45

Tested by

no test coverage detected