Implemented validate function.

This is the last exercise for the 'Validating Credit Card Numbers' part of
CIS 194 (2013) Homework 1.