(expectedValues)
| 12591 | } |
| 12592 | |
| 12593 | function createEnumTypeChecker(expectedValues) { |
| 12594 | if (!Array.isArray(expectedValues)) { |
| 12595 | return createChainableTypeChecker(function () { |
| 12596 | return new Error('Invalid argument supplied to oneOf, expected an instance of array.'); |
| 12597 | }); |
| 12598 | } |
| 12599 | |
| 12600 | function validate(props, propName, componentName, location, propFullName) { |
| 12601 | var propValue = props[propName]; |
| 12602 | for (var i = 0; i < expectedValues.length; i++) { |
| 12603 | if (propValue === expectedValues[i]) { |
| 12604 | return null; |
| 12605 | } |
| 12606 | } |
| 12607 | |
| 12608 | var locationName = ReactPropTypeLocationNames[location]; |
| 12609 | var valuesString = JSON.stringify(expectedValues); |
| 12610 | return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); |
| 12611 | } |
| 12612 | return createChainableTypeChecker(validate); |
| 12613 | } |
| 12614 | |
| 12615 | function createObjectOfTypeChecker(typeChecker) { |
| 12616 | function validate(props, propName, componentName, location, propFullName) { |
nothing calls this directly
no test coverage detected