All files / lib/dynamic-form-group dynamic-form-group-validator.ts

100% Statements 4/4
100% Branches 4/4
100% Functions 4/4
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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                                              12x       11x               3x       3x      
import { FormGroupBase } from '../dynamic-form-field/dynamic-form-field-control';
import {
  DynamicFormFieldAsyncValidator, DynamicFormFieldAsyncValidatorFactory, DynamicFormFieldAsyncValidatorFn,
  DynamicFormFieldValidator, DynamicFormFieldValidatorFactory, DynamicFormFieldValidatorFn,
} from '../dynamic-form-field/dynamic-form-field-validator';
import { DynamicFormGroup } from './dynamic-form-group';
 
export type DynamicFormGroupValidatorFn<Value extends { [key: string]: any } = any> =
  DynamicFormFieldValidatorFn<Value, FormGroupBase<Value>>;
 
export type DynamicFormGroupAsyncValidatorFn<Value extends { [key: string]: any } = any> =
  DynamicFormFieldAsyncValidatorFn<Value, FormGroupBase<Value>>;
 
export type DynamicFormGroupValidatorFactory<Value extends { [key: string]: any } = any, Model extends Value = Value> =
  DynamicFormFieldValidatorFactory<Value, Model, FormGroupBase<Value>, DynamicFormGroup<Value, Model>>;
 
export type DynamicFormGroupAsyncValidatorFactory<Value extends { [key: string]: any } = any, Model extends Value = Value> =
  DynamicFormFieldAsyncValidatorFactory<Value, Model, FormGroupBase<Value>, DynamicFormGroup<Value, Model>>;
 
export class DynamicFormGroupValidator<Value extends { [key: string]: any } = any, Model extends Value = Value>
  extends DynamicFormFieldValidator<Value, Model, FormGroupBase<Value>, DynamicFormGroup<Value, Model>> {
 
  constructor(factory: DynamicFormGroupValidatorFactory, key: string, field: DynamicFormGroup, deps?: any[]) {
    super(factory, key, field, deps);
  }
 
  protected getParameters(): any {
    return this.definition ? this.definition.parameters : this.field.template[this.key];
  }
}
 
export class DynamicFormGroupAsyncValidator<Value extends { [key: string]: any } = any, Model extends Value = Value>
  extends DynamicFormFieldAsyncValidator<Value, Model, FormGroupBase<Value>, DynamicFormGroup> {
 
  constructor(factory: DynamicFormGroupAsyncValidatorFactory, key: string, field: DynamicFormGroup, deps?: any[]) {
    super(factory, key, field, deps);
  }
 
  protected getParameters(): any {
    return this.definition ? this.definition.parameters : this.field.template[this.key];
  }
}