All files / pills-input si-pills-input-email.directive.ts

100% Statements 4/4
100% Branches 0/0
100% Functions 0/0
100% Lines 3/3

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 28 29                      1x                     1x       14x    
/**
 * Copyright (c) Siemens 2016 - 2025
 * SPDX-License-Identifier: MIT
 */
import { Directive, signal } from '@angular/core';
 
import { SiPillsInputPatternBase } from './si-pills-input-pattern-base';
import { SiPillsInputValueHandlerDirective } from './si-pills-input-value-handler';
 
// From Angular Email Validator
const EMAIL_REGEX =
  /^(?=.{1,254}$)(?=.{1,64}@)[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/g;
 
@Directive({
  selector: '[siPillsInputEmail]',
  providers: [
    {
      provide: SiPillsInputValueHandlerDirective,
      useExisting: SiPillsInputEmailDirective
    }
  ]
})
export class SiPillsInputEmailDirective extends SiPillsInputPatternBase {
  /**
   * @defaultValue signal(EMAIL_REGEX).asReadonly()
   */
  override readonly validationRegex = signal(EMAIL_REGEX).asReadonly();
}