MCPcopy Create free account
hub / github.com/ceph/ceph / verify_enum

Function verify_enum

src/python-common/ceph/deployment/utils.py:168–178  ·  view source on GitHub ↗
(field: Any, field_name: str, allowed: list)

Source from the content-addressed store, hash-verified

166
167
168def 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
181def validate_port(port: Optional[int], field_name: str = 'port') -> None:

Callers 1

validateMethod · 0.90

Calls 3

SpecValidationErrorClass · 0.90
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected