added validation to document creation