you need to look at lines 9 and 10 together. It's just a ?: conditional operator.
If there are errors - use helper function (it probably flattens various error messages, page level, field level, duplicate rules etc) to get 1 simple error message.
Else return an empty array.