Move credentials validation code to credentials class
Move validation code to credentials class