text: export var Schema = /*#__PURE__*/function () {
    function Schema(schema) {
      this.spec = void 0;
      this.data = void 0;
      this.spec = schema;
    }
  
    var _proto = Schema.prototype;
  
    _proto.getFieldType = function getFieldType(fieldName) {
      var _this$spec;
  
      return (_this$spec = this.spec) === null || _this$spec === void 0 ? void 0 : _this$spec[fieldName];
    };
  
    _proto.getKeys = function getKeys() {
      return Object.keys(this.spec);
    };
  
    _proto.setSchemaOptionsForAllType = function setSchemaOptionsForAllType(data) {
      var _this = this;
  
      if (data === this.data) {
        return;
      }
  
      Object.entries(this.spec).forEach(function (_ref) {
        var key = _ref[0],
            type = _ref[1];
        type.setSchemaOptions(_this.spec, data === null || data === void 0 ? void 0 : data[key]);
      });
      this.data = data;
    };
  
    _proto.checkForField = function checkForField(fieldName, data) {
      this.setSchemaOptionsForAllType(data);
      var fieldChecker = this.spec[fieldName];
  
      if (!fieldChecker) {
        // fieldValue can be anything if no schema defined
        return {
          hasError: false
        };
      }
  
      return fieldChecker.check(data[fieldName], data, fieldName);
    };
  
    _proto.checkForFieldAsync = function checkForFieldAsync(fieldName, data) {
      this.setSchemaOptionsForAllType(data);
      var fieldChecker = this.spec[fieldName];
  
      if (!fieldChecker) {
        // fieldValue can be anything if no schema defined
        return Promise.resolve({
          hasError: false
        });
      }
  
      return fieldChecker.checkAsync(data[fieldName], data, fieldName);
    };
  
    _proto.check = function check(data) {
      var _this2 = this;
  
      var checkResult = {};
      Object.keys(this.spec).forEach(function (key) {
        if (typeof data === 'object') {
          checkResult[key] = _this2.checkForField(key, data);
        }
      });
      return checkResult;
    };
  
    _proto.checkAsync = function checkAsync(data) {
      var _this3 = this;
  
      var checkResult = {};
      var promises = [];
      var keys = [];
      Object.keys(this.spec).forEach(function (key) {
        keys.push(key);
        promises.push(_this3.checkForFieldAsync(key, data));
      });
      return Promise.all(promises).then(function (values) {
        for (var i = 0; i < values.length; i += 1) {
          checkResult[keys[i]] = values[i];
        }
  
        return checkResult;
      });
    };
  
    return Schema;
  }();
  export function SchemaModel(o) {
    return new Schema(o);
  }
  
  SchemaModel.combine = function combine() {
    for (var _len = arguments.length, specs = new Array(_len), _key = 0; _key < _len; _key++) {
      specs[_key] = arguments[_key];
    }
  
    return new Schema(specs.map(function (model) {
      return model.spec;
    }).reduce(function (accumulator, currentValue) {
      return Object.assign(accumulator, currentValue);
    }, {}));
  };