Most people will tell you that we have a consensus to validate the transaction. But they are not fully correct.
Consensus helps the network agree on the ledger's state and doesn't validate it.
Blockchain Validators
A validator is someone responsible for verifying the transactions within the blockchain. Apart from adding security to the blockchain, there is no incentive to validate the transaction. Miners bundles a few transactions that are legitimate and put them into the block.
Before going for consensus, we have to validate each transaction.
The validation precedes the Consensus
Anyone running full-node can validate the transactions. Generally, miners validate the transaction as they maintain full nodes.
It doesn't attract miners as there is no incentive associated with validation.
Minner aims to create a new block to have rewards and transaction fees. In order to have a valid block, all the transactions should be valid otherwise block will be rejected by other nodes.
So the miner was left with no other choice, but to validate the transaction.
link this to a new article
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
https://www.quora.com/How-are-transactions-validated-in-Blockchain
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
nm nm
Example: