Open better2021 opened 5 years ago
validate: { is: ["^[a-z]+$",'i'], // 全匹配字母 is: /^[a-z]+$/i, // 全匹配字母,用规则表达式写法 not: ["[a-z]",'i'], // 不能包含字母 isEmail: true, // 检查邮件格式 isUrl: true, // 是否是合法网址 isIP: true, // 是否是合法IP地址 isIPv4: true, // 是否是合法IPv4地址 isIPv6: true, // 是否是合法IPv6地址 isAlpha: true, // 是否是字母 isAlphanumeric: true, // 是否是数字和字母 isNumeric: true, // 只允许数字 isInt: true, // 只允许整数 isFloat: true, // 是否是浮点数 isDecimal: true, // 是否是十进制书 isLowercase: true, // 是否是小写 isUppercase: true, // 是否大写 notNull: true, // 不允许为null isNull: true, // 是否是null notEmpty: true, // 不允许为空 equals: 'specific value', // 等于某些值 contains: 'foo', // 包含某些字符 notIn: [['foo', 'bar']], // 不在列表中 isIn: [['foo', 'bar']], // 在列表中 notContains: 'bar', // 不包含 len: [2,10], // 长度范围 isUUID: 4, // 是否是合法 uuids isDate: true, // 是否是有效日期 isAfter: "2011-11-05", // 是否晚于某个日期 isBefore: "2011-11-05", // 是否早于某个日期 max: 23, // 最大值 min: 23, // 最小值 isArray: true, // 是否是数组 isCreditCard: true, // 是否是有效信用卡号 // 自定义规则 isEven: function(value) { if(parseInt(value) % 2 != 0) { throw new Error('请输入偶数!') } }