<p dir="auto"><strong>Description</strong></p>
<p dir="auto">I'd like to propose a few steps to improve the validation constraints:</p>
<ul dir="auto">
<li>Deprecate empty strings (<code class="notranslate">""</code>) currently happily passing in string constraints (e.g. <code class="notranslate">Email</code>)
<ul dir="auto">
<li><a href="https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/Email.html" rel="nofollow">https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/Email.html</a></li>
</ul>
</li>
<li>Deprecate non string values in <code class="notranslate">NotBlank</code> / <code class="notranslate">Blank</code> and 'whitespaced' strings passing (<code class="notranslate">"   "</code>)
<ul dir="auto">
<li><a href="https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/NotBlank.html" rel="nofollow">https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/NotBlank.html</a></li>
<li>allow for null (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="338907755" data-permission-text="Title is private" data-url="https://github.com/symfony/symfony/issues/27876" data-hovercard-type="issue" data-hovercard-url="/symfony/symfony/issues/27876/hovercard" href="https://github.com/symfony/symfony/issues/27876">#27876</a>)</li>
</ul>
</li>
<li>Consider <code class="notranslate">NotEmpty</code> / <code class="notranslate">Empty</code> as the current <code class="notranslate">NotBlank</code> / <code class="notranslate">Blank</code> constraints
<ul dir="auto">
<li><a href="https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/NotEmpty.html" rel="nofollow">https://docs.jboss.org/hibernate/stable/beanvalidation/api/javax/validation/constraints/NotEmpty.html</a></li>
<li>I dont think we should add these (but favor specific constraints) as <code class="notranslate">empty</code> in PHP is different as described above (ints, bools, etc). Not sure we should follow either one :) thus possible confusion</li>
</ul>
</li>
</ul>
<p dir="auto">If this happens we'd do simply</p>
<ul dir="auto">
<li><code class="notranslate">@Email</code></li>
<li><code class="notranslate">@NotNull @Email</code></li>
<li><code class="notranslate">@NotNull @Length(min=3) @NotBlank</code></li>
<li><code class="notranslate">@NotNull @NotBlank</code></li>
<li><code class="notranslate">@Type(array) @Count(3)</code></li>
</ul>
<p dir="auto">Thoughts?</p>
<p dir="auto"><strong>Description</strong><br>
In most validators, there's a failsafe mecanism that prevent the validator from validating if it's a <code class="notranslate">null</code> value, as there's a validator for that (<code class="notranslate">NotNull</code>). I think <code class="notranslate">NotBlank</code> shouldn't bother on <code class="notranslate">null</code> values, especially as <code class="notranslate">NotBlank</code> and <code class="notranslate">NotNull</code> are used together to prevent <code class="notranslate">null</code> values too.</p>
<p dir="auto">Not really a feature request, but not really a bug too... more like a RFC but for all versions. But I guess this would be a BC break though. :/ So maybe add a deprecated on the validator if it's a null value or something, and remove the <code class="notranslate">null</code> invalidation from the <code class="notranslate">NotBlank</code> on 5.0 ?</p>
<p dir="auto">Currently, we need to reimplement the validator just to skip <code class="notranslate">null</code> values...</p>
<p dir="auto"><strong>Possible Solution</strong><br>
Either deprecate the validation on <code class="notranslate">null</code> value in <code class="notranslate">NotBlank</code>, or do as in most validators, (if <code class="notranslate">null</code> value, then skip). But as I mentionned, this would probably be a bc break.</p>