All files / lib/dynamic-form-dictionary dynamic-form-dictionary-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 44 45 46 47                                                    14x       15x                 3x       3x      
import { FormRecordBase } from '../dynamic-form-field/dynamic-form-field-control';
import {
  DynamicFormFieldAsyncValidator, DynamicFormFieldAsyncValidatorFactory, DynamicFormFieldAsyncValidatorFn,
  DynamicFormFieldValidator, DynamicFormFieldValidatorFactory, DynamicFormFieldValidatorFn,
} from '../dynamic-form-field/dynamic-form-field-validator';
import { DynamicFormDictionary } from './dynamic-form-dictionary';
 
export type DynamicFormDictionaryValidatorFn<Value = any> =
  DynamicFormFieldValidatorFn<{ [key: string]: Value }, FormRecordBase<Value>>;
 
export type DynamicFormDictionaryAsyncValidatorFn<Value = any> =
  DynamicFormFieldAsyncValidatorFn<{ [key: string]: Value }, FormRecordBase<Value>>;
 
export type DynamicFormDictionaryValidatorFactory<Value = any, Model extends Value = Value> =
  DynamicFormFieldValidatorFactory<{ [key: string]: Value }, { [key: string]: Model },
    FormRecordBase<Value>, DynamicFormDictionary<Value, Model>>;
 
export type DynamicFormDictionaryAsyncValidatorFactory<Value = any, Model extends Value = Value> =
  DynamicFormFieldAsyncValidatorFactory<{ [key: string]: Value }, { [key: string]: Model },
    FormRecordBase<Value>, DynamicFormDictionary<Value, Model>>;
 
export class DynamicFormDictionaryValidator<Value = any, Model extends Value = Value>
  extends DynamicFormFieldValidator<{ [key: string]: Value }, { [key: string]: Model },
    FormRecordBase<Value>, DynamicFormDictionary<Value, Model>> {
 
  constructor(factory: DynamicFormDictionaryValidatorFactory, key: string, field: DynamicFormDictionary, deps?: any[]) {
    super(factory, key, field, deps);
  }
 
  protected getParameters(): any {
    return this.definition ? this.definition.parameters : this.field.template[this.key];
  }
}
 
export class DynamicFormDictionaryAsyncValidator<Value = any, Model extends Value = Value>
  extends DynamicFormFieldAsyncValidator<{ [key: string]: Value }, { [key: string]: Model },
  FormRecordBase<Value>, DynamicFormDictionary<Value, Model>> {
 
  constructor(factory: DynamicFormDictionaryAsyncValidatorFactory, key: string, field: DynamicFormDictionary, deps?: any[]) {
    super(factory, key, field, deps);
  }
 
  protected getParameters(): any {
    return this.definition ? this.definition.parameters : this.field.template[this.key];
  }
}