'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _validation = require('../../../../utils/validation');

var _validation2 = _interopRequireDefault(_validation);

var _EmptyUtils = require('../../../../utils/EmptyUtils');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
 * Created by baoyinghai on 12/5/16.
 */
var validator = function validator(record, value, formValues, form) {
  var opt = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};

  var reg = new RegExp(opt.regex);
  if (!(0, _EmptyUtils.isEmpty)(value) && !reg.test(value)) {
    return new Error(opt.message || '不匹配正则');
  }
  return null;
};

exports.default = validator;