brew.validators¶
-
validators.
validate_grain_type
(grain_type)¶ Validate a grain type
Parameters: grain_type (str) – Type of Grain Returns: grain type Return type: str Raises: ValidatorException – If grain type is unknown
-
validators.
validate_hop_type
(hop_type)¶ Validate a hop type
Parameters: hop_type (str) – Type of Grain Returns: hop type Return type: str Raises: ValidatorException – If hop type is unknown
-
validators.
validate_percentage
(percent)¶ Validate decimal percentage
Parameters: percent (float) – Percentage between 0.0 and 1.0 Returns: percentage Return type: float Raises: ValidatorException – If decimal percentage not between 0.0 and 1.0
-
validators.
validate_units
(units)¶ Validate units
Parameters: units (str) – Unit type Returns: units Return type: str Raises: ValidatorException – If units is unknown
-
validators.
validate_required_fields
(data, required_fields)¶ Validate fields which are required as part of the data.
Parameters: - data (dict) – A python dictionary to check for required fields
- required_fields (list(tuple)) – Values and types to check for in data
Raises: - ValidatorException – Required field is missing from data
- ValidatorException – Required field is of the wrong type
The format is a list of tuples where the first element is a string with a value that should be a key found in the data dict and where the second element is a python type or list/tuple of python types to check the field against.
-
validators.
validate_optional_fields
(data, optional_fields, data_field=u'data')¶ Validate fields which are optional as part of the data.
Parameters: - data (dict) – A python dictionary to check for required fields
- optional_fields (list(tuple)) – Values and types to check for in data
- data_field (str) – The key in the data dictionary containing the optional fields
Raises: ValidatorException – Optional field is of the wrong type
The format is a list of tuples where the first element is a string with a value that should be a key found in the data dict and where the second element is a python type or list/tuple of python types to check the field against.