scratch-www/src/components/forms/validateMixin.jsx
Ray Schamp b5c615b1fa Use formsy-react for validation
Complete validation for username/password form (except for checking if a username exists).
2016-06-14 17:27:53 -04:00

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;