mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-12-13 01:01:29 -05:00
b5c615b1fa
Complete validation for username/password form (except for checking if a username exists).
24 lines
720 B
JavaScript
24 lines
720 B
JavaScript
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;
|