{"version":3,"sources":["../src/rules/has-prop.ts"],"sourcesContent":["/**\n * @file Checks an object to make sure that it has a certain property.\n * @name hasProp.js\n * @author Nick Krause\n * @license MIT\n */\nimport { createRule } from '../rule'\n\nexport const hasProp = (...properties: string[]) => {\n  let prop = ``\n  let currentObjectPath = {}\n\n  return createRule({\n    condition: (obj) => {\n      currentObjectPath = obj\n\n      for (const property of properties) {\n        if (currentObjectPath.hasOwnProperty(property)) {\n          prop = property\n          currentObjectPath = currentObjectPath[property]\n        } else {\n          return false\n        }\n      }\n\n      return true\n    },\n    message: (obj) => {\n      // list out the keys that we have\n      // to help us spot where things may have gone wrong prior\n      const keys = Object.keys(obj).toString().replace(`,`, `,\\n`)\n\n      return `Object containing properties ${keys} does not include ${prop}${\n        properties.length > 1 ? ` at path ${properties.join(`.`)}` : ``\n      }`\n    },\n  })\n}\n"],"mappings":";;;;;AAAA,AAQO,IAAM,UAAU,IAAI,eAAyB;AAClD,MAAI,OAAO;AACX,MAAI,oBAAoB,CAAC;AAEzB,SAAO,WAAW;AAAA,IAChB,WAAW,CAAC,QAAQ;AAClB,0BAAoB;AAEpB,iBAAW,YAAY,YAAY;AACjC,YAAI,kBAAkB,eAAe,QAAQ,GAAG;AAC9C,iBAAO;AACP,8BAAoB,kBAAkB;AAAA,QACxC,OAAO;AACL,iBAAO;AAAA,QACT;AAAA,MACF;AAEA,aAAO;AAAA,IACT;AAAA,IACA,SAAS,CAAC,QAAQ;AAGhB,YAAM,OAAO,OAAO,KAAK,GAAG,EAAE,SAAS,EAAE,QAAQ,KAAK;AAAA,CAAK;AAE3D,aAAO,gCAAgC,yBAAyB,OAC9D,WAAW,SAAS,IAAI,YAAY,WAAW,KAAK,GAAG,MAAM;AAAA,IAEjE;AAAA,EACF,CAAC;AACH;","names":[]}