moved validate to its own module