# Path: brew/constants.py
# GRAIN_TYPE_LIST = [
#     GRAIN_TYPE_CEREAL,
#     GRAIN_TYPE_SPECIALTY,
#     GRAIN_TYPE_DME,
#     GRAIN_TYPE_LME,
# ]
# 
# Path: brew/constants.py
# HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG]
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/exceptions.py
# class ValidatorException(BrewdayException):
#     pass


from .constants import GRAIN_TYPE_LIST
from .constants import HOP_TYPE_LIST
from .constants import IMPERIAL_UNITS
from .constants import SI_UNITS
from .exceptions import ValidatorException
# -*- coding: utf-8 -*-

__all__ = [
    u"validate_grain_type",
    u"validate_hop_type",
    u"validate_percentage",
    u"validate_units",
    u"validate_required_fields",
    u"validate_optional_fields",
]


def validate_grain_type(grain_type):
    """
    Validate a grain type

    :param str grain_type: Type of Grain
    :return: grain type
    :rtype: str
    :raises ValidatorException: If grain type is unknown
    """
    if grain_type in GRAIN_TYPE_LIST:
        return grain_type
    raise ValidatorException(
        u"Unkown grain type '{}', must use {}".format(

# Path: brew/constants.py
# GRAIN_TYPE_LIST = [
#     GRAIN_TYPE_CEREAL,
#     GRAIN_TYPE_SPECIALTY,
#     GRAIN_TYPE_DME,
#     GRAIN_TYPE_LME,
# ]
# 
# Path: brew/constants.py
# HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG]
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/exceptions.py
# class ValidatorException(BrewdayException):
#     pass


# Path: brew/validators.py
from .constants import GRAIN_TYPE_LIST
from .constants import HOP_TYPE_LIST
from .constants import IMPERIAL_UNITS
from .constants import SI_UNITS
from .exceptions import ValidatorException

# -*- coding: utf-8 -*-

__all__ = [
    u"validate_grain_type",
    u"validate_hop_type",
    u"validate_percentage",
    u"validate_units",
    u"validate_required_fields",
    u"validate_optional_fields",
]


def validate_grain_type(grain_type):
    """
    Validate a grain type

    :param str grain_type: Type of Grain
    :return: grain type
    :rtype: str
    :raises ValidatorException: If grain type is unknown
    """
    if grain_type in GRAIN_TYPE_LIST:
        return grain_type
    raise ValidatorException(
        u"Unkown grain type '{}', must use {}".format(

            grain_type, u", ".join(GRAIN_TYPE_LIST)