aria.ops.definition.assertions
1# Copyright 2022 VMware, Inc. 2# SPDX-License-Identifier: Apache-2.0 3from aria.ops.definition.exceptions import KeyException 4 5 6def validate_key(key: str, context: str) -> str: 7 if key is None: 8 raise KeyException(f"{context} key cannot be 'None'.") 9 if type(key) is not str: 10 raise KeyException(f"{context} key must be a string.") 11 if key == "": 12 raise KeyException(f"{context} key cannot be empty.") 13 if key.isspace(): 14 raise KeyException(f"{context} key cannot be blank.") 15 return key
def
validate_key(key: str, context: str) -> str:
7def validate_key(key: str, context: str) -> str: 8 if key is None: 9 raise KeyException(f"{context} key cannot be 'None'.") 10 if type(key) is not str: 11 raise KeyException(f"{context} key must be a string.") 12 if key == "": 13 raise KeyException(f"{context} key cannot be empty.") 14 if key.isspace(): 15 raise KeyException(f"{context} key cannot be blank.") 16 return key