import { PropertyValidator } from "../PropertyValidator" ; import { isIterable } from "../../shared/IsIterable" ; export class implements PropertyValidator < T > template T export class IsInValidator < T > implements PropertyValidator < T > { constructor ( private obj ) { } isValid ( input ) { if ( isIterable ( this . obj ) ) { return this . isElementOfIterable ( input ) ; } else { return this . isValueInObject ( input ) ; } } private isElementOfIterable ( input ) { for ( let element of this . obj ) { if ( element === input ) { return true ; } } return false ; } private isValueInObject ( input ) { return Object . keys ( this . obj ) . find ( key => this . obj [ key ] === input ) != null ; } }