def validate_fields(fields: typing.Union[AllowedFieldTypes, typing.List[AllowedFieldTypes]]):
    """Validates that the fields used in the filters are valid."""
    if not isinstance(fields, list):
        raise TypeError(f"Expected `fields` to be a list, got {type(fields)} instead.")

    any_required = False
    unique_names = set()
    for field in fields:
        if not isinstance(field, AllowedFieldTypes):
            raise TypeError(
                f"Expected `fields` to be a list of `{AllowedFieldTypes.__name__}`, got {type(field)} instead."
            )
        if field.name in unique_names:
            raise ValueError(f"Expected `fields` to have unique names, got {field.name} twice instead.")
        unique_names.add(field.name)
        if not any_required and field.required:
            any_required = True

    if not any_required:
        raise ValueError("At least one field in `fields` must be required (`required=True`).")
Validates that the fields used in the filters are valid.
argilla-v1/src/argilla_v1/client/feedback/dataset/helpers.py