"@mti2935"'s answer tells you how to validate the format of a public key. This may not help if an adversary uses a correctly formatted public key. There is another way to validate and find out if a correctly formatted key came from the original sender.
PGP supports that creation and use of certificate authorities (CA) for the public keys. A CA distributes public and private keys (only kept by the owner of the private key). Each of these public keys belong to a specific CA. The CAs hands out certificates that match to specific public keys. The certificate includes information about the SHA hash of the public key, the current owner of the public key, and both the issue and expiration date of the certificate. With the involvement of a secure hash algorithm in the certificate, it will be almost impossible to forge a public key with the same hash as the original sender’s public key. If a CA is involved, you can look at the hash of the key in the public key certificate. Calculate the secure hash of the public key and try to match it with the one in the certificate. If it does not match, then you do not have the original senders public key. If it matches, check to see if the date you received the key is within the issue and expiration date of the certificate. If it is outside of that range, then the certificate was not valid when the key was created. An invalid certificate when a key was created mean the key should not be trusted.