(json_data, allowed_sorts, default_sort)
| 143 | return view |
| 144 | |
| 145 | def validate_sort(json_data, allowed_sorts, default_sort): |
| 146 | sort = json_data.get("sort", default_sort) |
| 147 | |
| 148 | if sort == "no_sort": |
| 149 | sort = None |
| 150 | elif sort: |
| 151 | if not is_string_of_min_length(sort): |
| 152 | raise JsonHTTPResponseWithMessage( |
| 153 | "Sort must be a string with at least one character" |
| 154 | ) |
| 155 | |
| 156 | sort = sort.lower() |
| 157 | if sort not in allowed_sorts: |
| 158 | raise JsonHTTPResponseWithMessage( |
| 159 | f"Invalid sort. Must be one of: {', '.join(allowed_sorts)}." |
| 160 | ) |
| 161 | else: |
| 162 | sort = default_sort |
| 163 | return sort |
| 164 | |
| 165 | def validate_results_request(json_data, allowed_sorts, allowed_views, default_sort): |
| 166 | """Validates parameters for a task results request (excluding format).""" |
no test coverage detected