(field: Any, field_name: str, allowed: list)
| 166 | |
| 167 | |
| 168 | def verify_enum(field: Any, field_name: str, allowed: list) -> None: |
| 169 | if field: |
| 170 | allowed_lower = [] |
| 171 | if not isinstance(field, str): |
| 172 | raise SpecValidationError(f"{field_name} must be a string") |
| 173 | for val in allowed: |
| 174 | assert isinstance(val, str) |
| 175 | allowed_lower.append(val.lower()) |
| 176 | if field.lower() not in allowed_lower: |
| 177 | raise SpecValidationError( |
| 178 | f'Invalid {field_name}. Valid values are: {", ".join(allowed)}') |
| 179 | |
| 180 | |
| 181 | def validate_port(port: Optional[int], field_name: str = 'port') -> None: |
no test coverage detected