我有一个带有mat-input的mat-form-field,它位于一个material-table中 . 由于数据在material-table-datasource中,我不能使用formgroup并以这种方式验证输入 . 有没有其他方法或“解决方法”我可以用来解决这个问题?

该字段设置如下:

<ng-container matColumnDef="rate">
  <mat-header-cell *matHeaderCellDef mat-sort-header>Currency rate</mat-header-cell>
  <mat-cell class="description-cell" *matCellDef="let data">
    <mat-form-field class="rate-form-field">
      <input matInput [value]="data.currencyRate" (focusin)="setValue(data.currencyRate)" (focusout)="checkDirty($event, data)"  placeholder="Rate">
    </mat-form-field>
  </mat-cell>
</ng-container>

该值直接来自material-table-datasource . 在焦点上我保存当前值并在焦点输出上我根据输入字段中的实际值检查保存的值 . 如果不同,我会更改数据源中的值 . 我想要实现的是我尝试保存它是空的和/或无效的数字/字母,它应该在表单字段下面抛出一个错误 .