1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | 1× 1× | import Validator from 'validatorjs'; import Regexp from '../Regexp' import {isIdCard} from "../Type"; // 1.手机号验证器 Validator.register('phone', function(value, requirement, attribute) { return value.match(Regexp.phone); }, 'The :attribute phone number is vaild'); // 2.身份证号验证器 Validator.register('idcard', function(value, requirement, attribute) { return isIdCard(value,true); }, 'The :attribute phone number is vaild'); export default Validator |