I have an entity with fields that allow an unlimited number of values.
In a view, I would like to display a subset of those values that match a particular condition (eg. numbers less than n, dates in the past, etc.)
From investigation, it seems that a field formatter plugin is not a good way to solve this. Sure, I can extend DateTimeFormatterBase and override ::viewElements(FieldItemListInterface $items) to apply my condition, but at the price of being able to choose an actual field formatter. The custom plugin would have to take over the rendering too.
On the other hand, the Field plugin in views has some very limited options for limiting multiple values (by picking an offset and a count), but that doesn't seem extendable with a custom plugin.
Am I going to have to hook into the view after query execution to strip out the values that don't match the condition, or is there a cleaner way using the plugin API?
Edit: I suppose I could create a field formatter plugin that contains an option for selecting an actual formatter, and then passes the values that should be displayed on to it. This seems very roundabout, though. And this logic would have to be reimplemented for each field type!