iPhone X, iOS 12.1.2 - Whatsapp concern
You can change this option for any installed app in the Notifications section of the iOS Settings app. Tap on the appropriate app; at the bottom of the notifications setting screen, you can disable "Show Previews" (or set it to "When Unlocked") to prevent any details from being shown on your lock screen.