export enum HasKeysErrorCode { IS_NULL = "IS_NULL", IS_UNDEFINED = "IS_UNDEFINED", DOES_NOT_HAVE_KEY = "DOES_NOT_HAVE_KEY" } export function checkHasKeys (mixed : any, keys : T[]) : undefined|HasKeysErrorCode { if (mixed === null) { return HasKeysErrorCode.IS_NULL; } if (mixed === undefined) { return HasKeysErrorCode.IS_UNDEFINED; } for (let k of keys) { if (!mixed.hasOwnProperty(k)) { return HasKeysErrorCode.DOES_NOT_HAVE_KEY; } } return undefined; } export enum NotHasKeysErrorCode { IS_NULL = "IS_NULL", IS_UNDEFINED = "IS_UNDEFINED", HAS_KEY = "HAS_KEY" } export function checkNotHasKeys (mixed : any, keys : T[]) : undefined|NotHasKeysErrorCode { if (mixed === null) { return NotHasKeysErrorCode.IS_NULL; } if (mixed === undefined) { return NotHasKeysErrorCode.IS_UNDEFINED; } for (let k of keys) { if (mixed.hasOwnProperty(k)) { return NotHasKeysErrorCode.HAS_KEY; } } return undefined; }