Added some validation for database input based on types