For example I have a property
#[Groups(['show', 'admin])]
public mixed $name;
I want serializer to ignore the property, if all the groups aren't in the context. For example here by default it will still include it:
$this->json($user, context: ['groups' => ['show']]);
If u want to require all specified groups, you'll need to create a custom serializer. The default one does not provide any solution for that.
You should follow the structure of the NormalizerInterface, particularly using the supportsNormalization() method to verify when the custom normalizer should activate.
You can find the full documentation for Symfony's Serializer component in official Symfony docs - under The Serializer Component.
OR
If you have only 2 groups, you can add third one, for example show_admin
.