(json_data, allowed_views)
| 126 | return filters |
| 127 | |
| 128 | def validate_view(json_data, allowed_views): |
| 129 | view = json_data.get("view") |
| 130 | |
| 131 | if view: |
| 132 | if not is_string_of_min_length(view): |
| 133 | raise JsonHTTPResponseWithMessage( |
| 134 | "View must be a string with at least one character" |
| 135 | ) |
| 136 | |
| 137 | view = view.lower() |
| 138 | if view not in allowed_views: |
| 139 | raise JsonHTTPResponseWithMessage( |
| 140 | f"Invalid view. Must be one of: {', '.join(allowed_views)}." |
| 141 | ) |
| 142 | |
| 143 | return view |
| 144 | |
| 145 | def validate_sort(json_data, allowed_sorts, default_sort): |
| 146 | sort = json_data.get("sort", default_sort) |
no test coverage detected