{"version":3,"sources":["../src/disallowedIf.js"],"names":["disallowedIf","propType","otherPropName","otherPropType","isRequired","TypeError","disallowedIfRequired","props","propName","componentName","rest","error","otherError","Error","validator","disallowedIfPropType"],"mappings":";;;;;;;AAAA;;;;AAEe,SAASA,YAAT,CAAsBC,QAAtB,EAAgCC,aAAhC,EAA+CC,aAA/C,EAA8D;AAC3E,MAAI,OAAOF,QAAP,KAAoB,UAApB,IAAkC,OAAOA,QAAQ,CAACG,UAAhB,KAA+B,UAArE,EAAiF;AAC/E,UAAM,IAAIC,SAAJ,CAAc,uFAAd,CAAN;AACD;;AAED,MAAI,OAAOH,aAAP,KAAyB,QAA7B,EAAuC;AACrC,UAAM,IAAIG,SAAJ,CAAc,kCAAd,CAAN;AACD;;AAED,MAAI,OAAOF,aAAP,KAAyB,UAA7B,EAAyC;AACvC,UAAM,IAAIE,SAAJ,CAAc,uCAAd,CAAN;AACD;;AAED,WAASC,oBAAT,CAA8BC,KAA9B,EAAqCC,QAArC,EAA+CC,aAA/C,EAAuE;AAAA,sCAANC,IAAM;AAANA,MAAAA,IAAM;AAAA;;AACrE,QAAMC,KAAK,GAAGV,QAAQ,CAACG,UAAT,OAAAH,QAAQ,GAAYM,KAAZ,EAAmBC,QAAnB,EAA6BC,aAA7B,SAA+CC,IAA/C,EAAtB;;AACA,QAAIC,KAAJ,EAAW;AACT,aAAOA,KAAP;AACD;;AAED,QAAIJ,KAAK,CAACL,aAAD,CAAL,IAAwB,IAA5B,EAAkC;AAChC,aAAO,IAAP;AACD;;AAED,QAAMU,UAAU,GAAGT,aAAa,MAAb,UAAcI,KAAd,EAAqBL,aAArB,EAAoCO,aAApC,SAAsDC,IAAtD,EAAnB;;AACA,QAAIE,UAAJ,EAAgB;AACd,aAAO,IAAP;AACD;;AACD,WAAO,IAAIC,KAAJ,sBAAmBL,QAAnB,6CAAoDN,aAApD,2CAAP;AACD;;AAED,MAAMY,SAAS,GAAG,SAASC,oBAAT,CAA8BR,KAA9B,EAAqCC,QAArC,EAAwD;AACxE,QAAID,KAAK,CAACC,QAAD,CAAL,IAAmB,IAAvB,EAA6B;AAC3B,aAAO,IAAP;AACD;;AAHuE,uCAANE,IAAM;AAANA,MAAAA,IAAM;AAAA;;AAIxE,WAAOJ,oBAAoB,MAApB,UAAqBC,KAArB,EAA4BC,QAA5B,SAAyCE,IAAzC,EAAP;AACD,GALD;;AAOAI,EAAAA,SAAS,CAACV,UAAV,GAAuBE,oBAAvB;AAEA,SAAO,+BAAcQ,SAAd,EAAyB,cAAzB,EAAyC;AAAEb,IAAAA,QAAQ,EAARA,QAAF;AAAYC,IAAAA,aAAa,EAAbA,aAAZ;AAA2BC,IAAAA,aAAa,EAAbA;AAA3B,GAAzC,CAAP;AACD","sourcesContent":["import wrapValidator from './helpers/wrapValidator';\n\nexport default function disallowedIf(propType, otherPropName, otherPropType) {\n if (typeof propType !== 'function' || typeof propType.isRequired !== 'function') {\n throw new TypeError('a propType validator is required; propType validators must also provide `.isRequired`');\n }\n\n if (typeof otherPropName !== 'string') {\n throw new TypeError('other prop name must be a string');\n }\n\n if (typeof otherPropType !== 'function') {\n throw new TypeError('other prop type validator is required');\n }\n\n function disallowedIfRequired(props, propName, componentName, ...rest) {\n const error = propType.isRequired(props, propName, componentName, ...rest);\n if (error) {\n return error;\n }\n\n if (props[otherPropName] == null) {\n return null;\n }\n\n const otherError = otherPropType(props, otherPropName, componentName, ...rest);\n if (otherError) {\n return null;\n }\n return new Error(`prop “${propName}” is disallowed when “${otherPropName}” matches the provided validator`);\n }\n\n const validator = function disallowedIfPropType(props, propName, ...rest) {\n if (props[propName] == null) {\n return null;\n }\n return disallowedIfRequired(props, propName, ...rest);\n };\n\n validator.isRequired = disallowedIfRequired;\n\n return wrapValidator(validator, 'disallowedIf', { propType, otherPropName, otherPropType });\n}\n"],"file":"disallowedIf.js"}