import { PropertyValidator } from "../PropertyValidator" ; import { hasLength } from "../../shared/HasLength" ; import { hasSize } from "../../shared/HasSize" ; export class HasMaxNumberOfElementsValidator implements PropertyValidator < Iterable < any > > { constructor ( private maxElementCount ) { } isValid ( input ) { if ( hasLength ( input ) ) { return input . length <= this . maxElementCount ; } else if ( hasSize ( input ) ) { return input . size <= this . maxElementCount ; } else { return false ; } } }