title: Blazor: How do I check whether field is valid in OnFieldChanged
body: <p>I want to call a method when user changes a specific field AND the field value is valid.</p>
  <pre><code>&lt;EditForm EditContext=&quot;_editContext&quot;&gt;
     &lt;DataAnnotationValidator /&gt; //could be FluentValidator or anything else
     &lt;InputText @bind=&quot;Model.Username&quot; /&gt;
  &lt;/EditForm&gt;
  </code></pre>
  <pre><code>_editContext = new EditContext(Model);
  _editContext.FieldChanged(o, e) =&gt; {
     if (e.FieldIdentifier.Name == &quot;Username&quot;) {
         //how to check if field is valid
         //folowing does not work, because field has not been validated yet
         var hasSrrors = e.EditContext.GetValidationMessages(e.FieldIdentifier).Any();
     }
  };
  </code></pre>
  <p><strong>How do I check whether the field is valid after it has changed?</strong></p>
  <p>I've come with RX solution, but it is not perfect:</p>
  <pre class="lang-cs prettyprint-override"><code>Model.EditContext.FieldChangedObservable()
      .Where(fieldIdenitfier =&gt; fieldIdenitfier.Name == &quot;Username&quot;)
      //wait until validation
      .Select(_ =&gt; Model.EditContext.ValidationStateChangedObservable().FirstAsync())
      .Switch()
      //check barcode validation
      .Where(b =&gt; !Model!.EditContext.GetValidationMessages(FieldIdentifier.Create(() =&gt; Model.Entity.Barcode)).Any())
      .Subscribe(_ =&gt; MyFieldChanged());
  </code></pre>