Check if name field is a string before trimming it.