client/unified-form/validators/base.js

"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getUfValidator = getUfValidator;
require("core-js/modules/es.array.concat.js");
var _get2 = _interopRequireDefault(require("lodash/get"));
var _utils = require("../../helpers/utils");
var _coverTab = require("./cover-tab");
/**
 * Validate the unified form state
 *
 * @param {Function} validator - validator function
 * @returns {Function} - uf validator function
 */

function getUfValidator(validator) {
  return function (state, identifierTypes) {
    var jsonState = (0, _utils.convertMapToObject)(state);
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }
    return (0, _coverTab.validateISBN)((0, _get2.default)(jsonState, 'ISBN')) && validator.apply(void 0, [jsonState, identifierTypes].concat(args));
  };
}
//# sourceMappingURL=base.js.map