export enum OneOfErrorCode { NOT_ONE_OF = "NOT_ONE_OF" } export function checkOneOf (mixed : any, arr : T[]) : undefined|OneOfErrorCode { for (let item of arr) { if (mixed === item) { return undefined; } } return OneOfErrorCode.NOT_ONE_OF; } export enum NotOneOfErrorCode { IS_ONE_OF = "IS_ONE_OF" } export function checkNotOneOf (mixed : any, arr : NotT[]) : undefined|NotOneOfErrorCode { for (let item of arr) { if (mixed === item) { return NotOneOfErrorCode.IS_ONE_OF; } } return undefined; }