UNPKG

igi_orion_cignacmb

Version:

Censors words out of text

42 lines (37 loc) 1.37 kB
var CentralValidator = require('./CentralValidator'); var input = $.extend({}, CentralValidator, { validateMobile: function (value) { var result = { isCorrect: false, type: "modal", msg: "请输入", code: "", } // for (var i = 0; i < value.length; i++) { // var valueItem = value[i]; // if (!valueItem) { // result.isCorrect = false; // } // if (i == value.length - 1) { // if (!valueItem) { // result.isCorrect = true; // } // } // } return result; }, validate: function (name, value, type) { //用于验证,如有错误,返回数组,便于前端提示 var that = this; var errors = []; var runningFunc = that.validateMobile(); console.log(22222222222, runningFunc, name, value, type); for (var i = 0; i < value.length; i++) { var item = value[i]; if (((i != value.length - 1) && (i != value.length - 2)) && !item) { errors.push({type: runningFunc.type, msg: runningFunc.msg, code: runningFunc.code}); } } return errors.length > 0 ? errors : null; }, }); module.exports = input;