Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ValidatorMixin = {
- validate: function() {
- var obj = this.state[this.validationObject];
- var errors = {};
- for (var key in this.validationRules) {
- var rule = this.validationRules[key];
- if (!rule.valid(obj[key])) {
- errors[key] = rule.message;
- }
- }
- if (Object.keys(errors).length === 0) {
- this.setState({errors: null});
- return true;
- } else {
- this.setState({errors: errors});
- return false;
- }
- }
- };
- var ValidationRules = {
- notEmptyHtml: function(v) {
- v = v.replace(/<\/?[a-z]*>/g, '');
- v = v.replace(/ /g, '');
- return !String.isEmpty(v);
- }
- };
- module.exports = {
- mixin: ValidatorMixin,
- rules: ValidationRules
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement