Check out example codes for "engineering adding requirements to password". It will help you in understanding the concepts better.

Code Example 1

To be honest, I find having strict password requirements to 
be an annoyance and not a benefit. I would say as a rule the 
most reasonable is to just specify a length, maybe special 
characters + alphanumeric. Anything more is asking for people 
to write down their password, which defeats the whole purpose 
of having secure passwords. I also hate having to change your
password every x days with the usual ridiculous set of rules 
(e.g. cannot re-use the last 25 passwords) - again all that 
does is force people to write the thing down so they don't 
forget, at which point you might as well not ask 
for a password at all.

Learn ReactJs, React Native from akashmittal.com