colour.utilities.validate_method

colour.utilities.validate_method(method: str, valid_methods: Union[Sequence, Mapping], message: str = '"{0}" method is invalid, it must be one of {1}!') str[source]

Validate whether given method exists in the given valid methods and returns the method lower cased.

Parameters
  • method (str) – Method to validate.

  • valid_methods (Union[Sequence, Mapping]) – Valid methods.

  • message (str) – Message for the exception.

Returns

Method lower cased.

Return type

str

Raises

ValueError – If the method does not exist.

Examples

>>> validate_method('Valid', ['Valid', 'Yes', 'Ok'])
'valid'