In my experience, every field is required unless otherwise indicated. This is a HUGE ongoing debate but in my experience and testing with my users I only show input fields that are required. However, if you do want to show an optional field, add an optional indicator.
Phone Number (Optional)
Treat it like any other input field. Once it has a value, it is now required to be properly validated. If it is not valid then you can show an error state under the input field.
The way you worded your question tells me you are a developer with some experience in UX. While you are designing you need to take off your developer hat. It does not matter how you will technically build this form. First design your form the way your users would expect to interact with it. Case in point, when a user clicks submit.... they expect it to submit, not see a modal/popup with more junk to read and make decisions.
Once this is done, then dive into how you will execute it. If not you will find your designs will feel technical appose to simple and delightful.
Note: Your error state example is not ideal. Design with Error Prevention first then design for Error Identification. In this case you are letting the user make an error. If so, once there is an error, you as the designer know whats wrong.... so tell them how to fix it. Better yet fix it for them or even give them options to resolve the error.
Telling them that something might be wrong just creates a unpleasant and confusing experience.