Valency can be defined as the combining capacity of an atom. From the Bohr-Bury model model we know that electrons in the outermost orbit tries to complete their octet (i.e. they always try to have 8 electrons in their outermost orbit). In order to complete their octet atoms lose, gain or share their electrons to other atoms of same or other element. And the number of electrons exchange during the process gives us the valency.
For example hydrogen has one electron in its outer most orbit so in order to complete its octet he has two option either he can gain ‘7’ electron or share his ‘1’ electron with another atom in such a way that he had ‘8’ electrons in its outermost orbit. So first he share his electron with another hydrogen atom and have 2 electrons in its outermost orbit. Now he looks for an atom who had 6 electron in its outermost orbit and ready to share his electrons. hydrogen find oxygen who had 6 electron in its outermost orbit and by sharing their electrons they complete their octet.