text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.regex = exports.ref = exports.len = exports.req = exports.withParams = undefined;
  
  var _withParams = require('../withParams');
  
  var _withParams2 = _interopRequireDefault(_withParams);
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  exports.withParams = _withParams2.default;
  
  // "required" core, used in almost every validator to allow empty values
  
  var req = exports.req = function req(value) {
    if (Array.isArray(value)) return !!value.length;
    if (value === undefined || value === null || value === false) {
      return false;
    }
  
    if (typeof value === 'object') {
      for (var _ in value) {
        return true;
      }return false;
    }
  
    return !!String(value).length;
  };
  
  // get length in type-agnostic way
  var len = exports.len = function len(value) {
    if (Array.isArray(value)) return value.length;
    if (typeof value === 'object') {
      return Object.keys(value).length;
    }
    return String(value).length;
  };
  
  // resolve referenced value
  var ref = exports.ref = function ref(reference, vm, parentVm) {
    return typeof reference === 'function' ? reference.call(vm, parentVm) : parentVm[reference];
  };
  
  // regex based validator template
  var regex = exports.regex = function regex(type, expr) {
    return (0, _withParams2.default)({ type: type }, function (value) {
      return !req(value) || expr.test(value);
    });
  };