Skip to content

Commit

Permalink
Use validateProps in .update
Browse files Browse the repository at this point in the history
  • Loading branch information
ojab committed Oct 3, 2017
1 parent ff145e1 commit 4276005
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ export function getPropTypesMixin(userOpts) {

// Run validators for only the props passed in, not
// all declared PropTypes.
Object.keys(props).forEach((key) => {
const propTypesToValidate = Object.keys(props).reduce((result, key) => {
if (Object.prototype.hasOwnProperty.call(propTypes, key)) {
const validator = propTypes[key];
validateProp(validator, props, key, `${modelName}.update`);
return { ...result, [key]: propTypes[key] };
}
});
return result;
}, {});
validateProps(props, propTypesToValidate, `${modelName}.update`);
}

return super.update(...args);
Expand Down

0 comments on commit 4276005

Please sign in to comment.