UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

57 lines (56 loc) 2.87 kB
import { EventEmitter, StaticProvider } from '@angular/core'; import { AsyncValidator, FormControl, ValidationErrors } from '@angular/forms'; import { Observable, Subject } from 'rxjs'; import { AsyncValidationAlerts, ValidationAlerts } from '../validation-alert/validation-alert'; import { FormAsyncValidatorBase } from '../validators/base-async-validator'; import { SmeAsyncValidator } from '../validators/sme-async-validator'; import * as i0 from "@angular/core"; /** * Arguments for the @see FormFieldAsyncValidatorDirective.customAsyncValidate Output event */ export interface CheckAsyncValidationEventArgs { /** * The form control that we are validating */ formControl: FormControl; /** * An observable that emits an alert object when complete */ alerts: AsyncValidationAlerts; } /** * Provider for the FormFieldAsyncValidatorDirective directive */ export declare const FORM_FIELD_ASYNC_VALIDATOR: StaticProvider; export declare const defaultAsyncValidationDebounceTime = 800; /** * Implementation of Async Validator for sme-form-field * The selector for this directive must match @see FormFieldComponent.selector. see FormFieldComponent for details. */ export declare class FormFieldAsyncValidatorDirective extends FormAsyncValidatorBase implements AsyncValidator { private asyncValidators; customAsyncValidateDisabled: boolean; customAsyncValidateDebounceTime: number; /** * EventEmitter for checking validation and raising alerts * Subscribers are expected to populate the 'alerts' map with their own validation alerts */ customAsyncValidate: EventEmitter<CheckAsyncValidationEventArgs>; /** * Subject to emit when new alerts are available */ asyncAlert: Subject<ValidationAlerts>; /** * Instantiates a new instance of FormFieldAsyncValidatorDirective */ constructor(asyncValidators: Array<SmeAsyncValidator>); /** * Implementation of Validator interface. * Validates the value of this elements form control. Use the @see checkValidate event to hook into this function. * @param c The FormControl attached to this element * @return null when valid, otherwise returns a validation object in the form of "{ errorType: {valid: false} }". */ validate(c: FormControl): Observable<ValidationErrors | null>; static ɵfac: i0.ɵɵFactoryDeclaration<FormFieldAsyncValidatorDirective, [{ optional: true; self: true; }]>; static ɵdir: i0.ɵɵDirectiveDeclaration<FormFieldAsyncValidatorDirective, "sme-form-field[customAsyncValidate]", never, { "customAsyncValidateDisabled": "customAsyncValidateDisabled"; "customAsyncValidateDebounceTime": "customAsyncValidateDebounceTime"; }, { "customAsyncValidate": "customAsyncValidate"; }, never, never, false, never>; }