in the validate function, check if ids actually exist in the database.