from typing import Optional


def validate_commodity(commodity: Optional[str]) -> Optional[str]:
    """
    Validates the commodity of an object.

    :param commodity: The commodity of the object.
    :return: The validated commodity.
    """
    if commodity is None:
        # Skip validation if no value provided
        return None
    if not commodity:
        raise ValueError("Commodity must not be empty.")
    if len(commodity) > 255:
        raise ValueError("Commodity must not be longer than 255 characters.")

    return commodity