Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when adding an errors container). Here’s the code snippet that allows you to check for the errors form variable:

{% if form.vars.errors or form.fieldName.vars.errors %}
...
{% endif %}