All files / src/app/shared/formly/wrappers/validation-wrapper validation-wrapper.component.ts

100% Statements 5/5
100% Branches 7/7
100% Functions 1/1
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 281x 1x                                 1x   6x              
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { FieldWrapper } from '@ngx-formly/core';
 
/**
 *  Wrapper to provide validation feedback and styling to fields.
 *
 *  @props **required** - special validation case that is considered.
 *
 * @usageNotes
 * This wrapper uses the ``<ish-validation-message>`` and  ``<ish-validation-icons>`` components  to display validation messages
 * and icons depending on the fields validity as well as provide some necessary styling.
 * Refer to the components' documentation for more information.
 */
@Component({
  selector: 'ish-validation-wrapper',
  templateUrl: './validation-wrapper.component.html',
  changeDetection: ChangeDetectionStrategy.Default,
})
export class ValidationWrapperComponent extends FieldWrapper {
  showValidationIcons() {
    return (
      Object.keys(this.field.validators ?? {}).length ||
      Object.keys(this.field.asyncValidators ?? {}).length ||
      this.field.props?.required
    );
  }
}