Better osmid validation function