import { ValidatorFn , AbstractControl } from "@angular/forms" ; import { ObjectMaker } from "../util/object-maker" ; import { ArrayConfig } from "../models/config/array-config" ; import { AnnotationTypes } from "../core/validator.static" ; import { ValidatorValueChecker } from "../util/validator-value-checker" ; import { getConfigObject } from "../util/config-provider" ; import { ARRAY_CONFIG } from "../const/config-names.const" ; export function allOfValidator ( configModel ) { return ( control ) : { [ key ] : any ; } => { let config = getConfigObject ( configModel , control , ARRAY_CONFIG ) ; if ( ValidatorValueChecker . passArrayValue ( control , config ) ) { var testResult = false ; for ( let value of config . matchValues ) { testResult = control . value . some ( ( y ) => y == value ) ; if ( ! testResult ) break ; } if ( ! testResult ) return ObjectMaker . toJson ( AnnotationTypes . allOf , config , [ control . value ] ) ; } return ObjectMaker . null ( ) ; } ; }