Skip to content

Commit

Permalink
Adding validation for arrayOf and objectOf in ReactPropTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
chicoxyzzy committed Nov 4, 2015
1 parent 4573cd8 commit a180f60
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/isomorphic/classic/types/ReactPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ function createArrayOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new Error(
`Invalid argument \`${propFullName}\` of type ` +
`\`${typeof typeChecker}\` supplied to \`${componentName}\`, expected valid PropType.`
`Invalid argument \`${propFullName}\` supplied to \`${componentName}\`, expected valid PropType.`
);
}
var propValue = props[propName];
Expand Down Expand Up @@ -238,8 +237,7 @@ function createObjectOfTypeChecker(typeChecker) {
function validate(props, propName, componentName, location, propFullName) {
if (typeof typeChecker !== 'function') {
return new Error(
`Invalid argument \`${propFullName}\` of type ` +
`\`${typeof typeChecker}\` supplied to \`${componentName}\`, expected valid PropType.`
`Invalid argument \`${propFullName}\` supplied to \`${componentName}\`, expected valid PropType.`
);
}
var propValue = props[propName];
Expand Down
4 changes: 2 additions & 2 deletions src/isomorphic/classic/types/__tests__/ReactPropTypes-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ describe('ReactPropTypes', function() {
typeCheckFail(
PropTypes.arrayOf({ foo: PropTypes.string }),
{ foo: 'bar' },
'Invalid argument `testProp` of type `object` supplied to `testComponent`, expected valid PropType.'
'Invalid argument `testProp` supplied to `testComponent`, expected valid PropType.'
);
});

Expand Down Expand Up @@ -473,7 +473,7 @@ describe('ReactPropTypes', function() {
typeCheckFail(
PropTypes.objectOf({ foo: PropTypes.string }),
{ foo: 'bar' },
'Invalid argument `testProp` of type `object` supplied to `testComponent`, expected valid PropType.'
'Invalid argument `testProp` supplied to `testComponent`, expected valid PropType.'
);
});

Expand Down

0 comments on commit a180f60

Please sign in to comment.