I am making a posting application. The content of the post is an image, text, and title.
It seems that validation is not working when you make a new post, so even if you press the post button without filling in, it will go to the person who succeeded in creating the conditional branch (the image diagram is shown below).

How can I validate and process render: new?

[New post page]

[Even if you press the post button without filling in, you will go to redirect_to root_path]

Corresponding source code
[Posts controller]
class PostsController</pre>
<pre><code data-language = "rail">[Posting screen]

    <% = form_with (model: @post, local: true) do | form |%>
      <% if @ post.errors.any?%>
      <% = render'shared/error_messages', model: form.object%>
      <% end%>
      <% = form.file_field: image, placeholder: "URL of image"%>
      <% = form.text_area: title, placeholder: "Title (up to 50 characters", rows: "1"%>
      <% = form.text_area: text, placeholder: "content (up to 50 characters)", rows: "5"%>
      <% = form.submit "SEND"%>
    <% end%>
class Post
Supplementary information (FW/tool version, etc.)