implement document validation