colour.utilities.validate_method

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

Validates whether given method exists in the given valid methods and returns the method lower cased. If the method does not exist a ValueError exception is raised.

Parameters
  • method (unicode) – Method to validate.

  • valid_methods (array_like) – Valid methods.

  • message (unicode, optional) – Message for the exception.

Returns

Method lower cased.

Return type

unicode

Examples

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