def METHOD_NAME(self, values):
    if not values and self.required:
        error_msg = _(
            "Field can't be empty. Please put the item OR items separated "
            "by new line or comma."
        )
        raise forms.ValidationError(error_msg, code='required')
    non_empty_values = [
        item for item in values if str(item).strip()
    ]
    if not self.allow_duplicates:
        has_duplicates = len(set(non_empty_values)) != len(non_empty_values)
        if has_duplicates:
            raise forms.ValidationError(_("There are duplicates in field."))