Data format validation error messages should appear close to the UI element that contains the offending user input.
There are also "remote validation" errors, which happen when the user enters an invalid value that based on all other existing records. A common one is trying to register a user name that's already taken.
If it's a remote validation error for one field, it should also appear in the same place as an data format error message close to the UI element (most likely a single-line text box).
There are some violations, though, that result from just the wrong combination of values (even properly formatted) in multiple input elements. I would put such error message away from input elements so that the user can focus on what's wrong in one reading.
10-15 years ago, I put an error summary on the top of the page because form submission required a full page post back. Since the user will read from top to bottom, I wanted them to immediately see what they did wrong (and the error text is in red). Now, when I know form submission will not require a full page postback, I would put the error summary above the submit button because the user is already at that location.