mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-01-05 20:12:02 -05:00
25 lines
720 B
React
25 lines
720 B
React
|
var defaults = require('lodash.defaultsdeep');
|
||
|
var React = require('react');
|
||
|
|
||
|
var validateMixin = function (Component) {
|
||
|
var ValidatedComponent = React.createClass({
|
||
|
getDefaultValidationErrors: function () {
|
||
|
return {
|
||
|
isDefaultRequiredValue: 'This field is required'
|
||
|
};
|
||
|
},
|
||
|
render: function () {
|
||
|
var validationErrors = defaults(
|
||
|
this.getDefaultValidationErrors(),
|
||
|
this.props.validationErrors
|
||
|
);
|
||
|
return (
|
||
|
<Component {...this.props} validationErrors={validationErrors} />
|
||
|
);
|
||
|
}
|
||
|
});
|
||
|
return ValidatedComponent;
|
||
|
};
|
||
|
|
||
|
module.exports = validateMixin;
|