Just use either inheritance or object variants, whichever lends itself better to your use case. You can't get sum types from composition alone, which leads to product types, and you need sum types here.
The rule "composition over inheritance" is for a different situation, where inheritance gets abused as a form of composition (for example, because a language does not support value types natively and you want to avoid additional levels of indirection). And the for the "composite pattern", composition is only part of the pattern.
