added generic function to validate entity IDs