extract validation logic to a separate class

Change-Id: I8cc511b4121fcbcc8e922e2253953d8bfeeffb24