MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / createEnumTypeChecker

Function createEnumTypeChecker

examples/simple/react.js:12593–12613  ·  view source on GitHub ↗
(expectedValues)

Source from the content-addressed store, hash-verified

12591}
12592
12593function 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
12615function createObjectOfTypeChecker(typeChecker) {
12616 function validate(props, propName, componentName, location, propFullName) {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected