def rating_value(value):
    """Check that given value is integer and between 1 and 5."""
    if 1 <= int(value) <= 5:
        return int(value)
    raise ValueError("Expected rating between 1 and 5, but got %s" % value)