'use strict';
var formats = require('ajv/lib/compile/formats')();
var equal = require('ajv/lib/compile/equal');
var validate = (function() {
  var refVal = [];
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
    'use strict'; /*# sourceURL=https://formats.openag.io/oada/harvest/v1.schema.json */
    var vErrors = null;
    var errors = 0;
    if (rootData === undefined) rootData = data;
    if ((data && typeof data === "object" && !Array.isArray(data))) {
      if (true) {
        var errs__0 = errors;
        var valid1 = true;
        var data1 = data['as-harvested'];
        if (data1 === undefined) {
          valid1 = true;
        } else {
          var errs_1 = errors;
          if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
            if (true) {
              var errs__1 = errors;
              var valid2 = true;
              if (data1._id === undefined) {
                valid2 = false;
                validate.errors = [{
                  keyword: 'required',
                  dataPath: (dataPath || '') + '[\'as-harvested\']',
                  schemaPath: '#/properties/as-harvested/required',
                  params: {
                    missingProperty: '_id'
                  },
                  message: 'should have required property \'_id\''
                }];
                return false;
              } else {
                var errs_2 = errors;
                if (typeof data1._id !== "string") {
                  validate.errors = [{
                    keyword: 'type',
                    dataPath: (dataPath || '') + '[\'as-harvested\']._id',
                    schemaPath: '#/properties/as-harvested/properties/_id/type',
                    params: {
                      type: 'string'
                    },
                    message: 'should be string'
                  }];
                  return false;
                }
                var valid2 = errors === errs_2;
              }
              if (valid2) {
                var data2 = data1._rev;
                if (data2 === undefined) {
                  valid2 = false;
                  validate.errors = [{
                    keyword: 'required',
                    dataPath: (dataPath || '') + '[\'as-harvested\']',
                    schemaPath: '#/properties/as-harvested/required',
                    params: {
                      missingProperty: '_rev'
                    },
                    message: 'should have required property \'_rev\''
                  }];
                  return false;
                } else {
                  var errs_2 = errors;
                  if ((typeof data2 !== "number" || (data2 % 1) || data2 !== data2)) {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '[\'as-harvested\']._rev',
                      schemaPath: '#/properties/as-harvested/properties/_rev/type',
                      params: {
                        type: 'integer'
                      },
                      message: 'should be integer'
                    }];
                    return false;
                  }
                  var valid2 = errors === errs_2;
                }
                if (valid2) {}
              }
              if (errs__1 == errors) {}
            }
          } else {
            validate.errors = [{
              keyword: 'type',
              dataPath: (dataPath || '') + '[\'as-harvested\']',
              schemaPath: '#/properties/as-harvested/type',
              params: {
                type: 'object'
              },
              message: 'should be object'
            }];
            return false;
          }
          if (errors === errs_1) {}
          var valid1 = errors === errs_1;
        }
        if (valid1) {
          var data1 = data['tiled-maps'];
          if (data1 === undefined) {
            valid1 = true;
          } else {
            var errs_1 = errors;
            if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
              if (true) {
                var errs__1 = errors;
                var valid2 = true;
                if (data1._id === undefined) {
                  valid2 = false;
                  validate.errors = [{
                    keyword: 'required',
                    dataPath: (dataPath || '') + '[\'tiled-maps\']',
                    schemaPath: '#/properties/tiled-maps/required',
                    params: {
                      missingProperty: '_id'
                    },
                    message: 'should have required property \'_id\''
                  }];
                  return false;
                } else {
                  var errs_2 = errors;
                  if (typeof data1._id !== "string") {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '[\'tiled-maps\']._id',
                      schemaPath: '#/properties/tiled-maps/properties/_id/type',
                      params: {
                        type: 'string'
                      },
                      message: 'should be string'
                    }];
                    return false;
                  }
                  var valid2 = errors === errs_2;
                }
                if (valid2) {
                  var data2 = data1._rev;
                  if (data2 === undefined) {
                    valid2 = false;
                    validate.errors = [{
                      keyword: 'required',
                      dataPath: (dataPath || '') + '[\'tiled-maps\']',
                      schemaPath: '#/properties/tiled-maps/required',
                      params: {
                        missingProperty: '_rev'
                      },
                      message: 'should have required property \'_rev\''
                    }];
                    return false;
                  } else {
                    var errs_2 = errors;
                    if ((typeof data2 !== "number" || (data2 % 1) || data2 !== data2)) {
                      validate.errors = [{
                        keyword: 'type',
                        dataPath: (dataPath || '') + '[\'tiled-maps\']._rev',
                        schemaPath: '#/properties/tiled-maps/properties/_rev/type',
                        params: {
                          type: 'integer'
                        },
                        message: 'should be integer'
                      }];
                      return false;
                    }
                    var valid2 = errors === errs_2;
                  }
                  if (valid2) {}
                }
                if (errs__1 == errors) {}
              }
            } else {
              validate.errors = [{
                keyword: 'type',
                dataPath: (dataPath || '') + '[\'tiled-maps\']',
                schemaPath: '#/properties/tiled-maps/type',
                params: {
                  type: 'object'
                },
                message: 'should be object'
              }];
              return false;
            }
            if (errors === errs_1) {}
            var valid1 = errors === errs_1;
          }
          if (valid1) {
            if (data._id === undefined) {
              valid1 = true;
            } else {
              var errs_1 = errors;
              if (typeof data._id !== "string") {
                validate.errors = [{
                  keyword: 'type',
                  dataPath: (dataPath || '') + '._id',
                  schemaPath: '#/properties/_id/type',
                  params: {
                    type: 'string'
                  },
                  message: 'should be string'
                }];
                return false;
              }
              var valid1 = errors === errs_1;
            }
            if (valid1) {
              var data1 = data._rev;
              if (data1 === undefined) {
                valid1 = true;
              } else {
                var errs_1 = errors;
                if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
                  validate.errors = [{
                    keyword: 'type',
                    dataPath: (dataPath || '') + '._rev',
                    schemaPath: '#/properties/_rev/type',
                    params: {
                      type: 'integer'
                    },
                    message: 'should be integer'
                  }];
                  return false;
                }
                var valid1 = errors === errs_1;
              }
              if (valid1) {
                var data1 = data._meta;
                if (data1 === undefined) {
                  valid1 = true;
                } else {
                  var errs_1 = errors;
                  if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
                    if (true) {
                      var errs__1 = errors;
                      var valid2 = true;
                      if (data1._id === undefined) {
                        valid2 = false;
                        validate.errors = [{
                          keyword: 'required',
                          dataPath: (dataPath || '') + '._meta',
                          schemaPath: '#/properties/_meta/required',
                          params: {
                            missingProperty: '_id'
                          },
                          message: 'should have required property \'_id\''
                        }];
                        return false;
                      } else {
                        var errs_2 = errors;
                        if (typeof data1._id !== "string") {
                          validate.errors = [{
                            keyword: 'type',
                            dataPath: (dataPath || '') + '._meta._id',
                            schemaPath: '#/properties/_meta/properties/_id/type',
                            params: {
                              type: 'string'
                            },
                            message: 'should be string'
                          }];
                          return false;
                        }
                        var valid2 = errors === errs_2;
                      }
                      if (valid2) {
                        var data2 = data1._rev;
                        if (data2 === undefined) {
                          valid2 = false;
                          validate.errors = [{
                            keyword: 'required',
                            dataPath: (dataPath || '') + '._meta',
                            schemaPath: '#/properties/_meta/required',
                            params: {
                              missingProperty: '_rev'
                            },
                            message: 'should have required property \'_rev\''
                          }];
                          return false;
                        } else {
                          var errs_2 = errors;
                          if ((typeof data2 !== "number" || (data2 % 1) || data2 !== data2)) {
                            validate.errors = [{
                              keyword: 'type',
                              dataPath: (dataPath || '') + '._meta._rev',
                              schemaPath: '#/properties/_meta/properties/_rev/type',
                              params: {
                                type: 'integer'
                              },
                              message: 'should be integer'
                            }];
                            return false;
                          }
                          var valid2 = errors === errs_2;
                        }
                        if (valid2) {}
                      }
                      if (errs__1 == errors) {}
                    }
                  } else {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '._meta',
                      schemaPath: '#/properties/_meta/type',
                      params: {
                        type: 'object'
                      },
                      message: 'should be object'
                    }];
                    return false;
                  }
                  if (errors === errs_1) {}
                  var valid1 = errors === errs_1;
                }
                if (valid1) {
                  if (data._type === undefined) {
                    valid1 = false;
                    validate.errors = [{
                      keyword: 'required',
                      dataPath: (dataPath || '') + "",
                      schemaPath: '#/required',
                      params: {
                        missingProperty: '_type'
                      },
                      message: 'should have required property \'_type\''
                    }];
                    return false;
                  } else {
                    var errs_1 = errors;
                    var schema1 = validate.schema.properties._type.enum;
                    var valid1;
                    valid1 = false;
                    for (var i1 = 0; i1 < schema1.length; i1++)
                      if (equal(data._type, schema1[i1])) {
                        valid1 = true;
                        break;
                      } if (!valid1) {
                      validate.errors = [{
                        keyword: 'enum',
                        dataPath: (dataPath || '') + '._type',
                        schemaPath: '#/properties/_type/enum',
                        params: {
                          allowedValues: schema1
                        },
                        message: 'should be equal to one of the allowed values'
                      }];
                      return false;
                    } else {}
                    if (errors === errs_1) {}
                    var valid1 = errors === errs_1;
                  }
                  if (valid1) {}
                }
              }
            }
          }
        }
        if (errs__0 == errors) {}
      }
    } else {
      validate.errors = [{
        keyword: 'type',
        dataPath: (dataPath || '') + "",
        schemaPath: '#/type',
        params: {
          type: 'object'
        },
        message: 'should be object'
      }];
      return false;
    }
    if (errors === 0) {}
    validate.errors = vErrors;
    return errors === 0;
  };
})();
validate.schema = {
  "$id": "https://formats.openag.io/oada/harvest/v1.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "A harvest document holds links to information related to harvest activites or data.",
  "properties": {
    "as-harvested": {
      "description": "A versioned link in OADA has _id an _rev in the link in order allow changes to bubble up from child to parents.",
      "properties": {
        "_id": {
          "description": "_id identifies a resource in the OADA API.",
          "type": "string"
        },
        "_rev": {
          "description": "_rev is the revision string for a resource in the OADA API.",
          "type": "integer"
        }
      },
      "required": ["_id", "_rev"],
      "type": "object"
    },
    "tiled-maps": {
      "description": "A versioned link in OADA has _id an _rev in the link in order allow changes to bubble up from child to parents.",
      "properties": {
        "_id": {
          "description": "_id identifies a resource in the OADA API.",
          "type": "string"
        },
        "_rev": {
          "description": "_rev is the revision string for a resource in the OADA API.",
          "type": "integer"
        }
      },
      "required": ["_id", "_rev"],
      "type": "object"
    },
    "_id": {
      "description": "_id identifies a resource in the OADA API.",
      "type": "string"
    },
    "_rev": {
      "description": "_rev is the revision string for a resource in the OADA API.",
      "type": "integer"
    },
    "_meta": {
      "description": "_meta is a link to the meta document for a resources.",
      "properties": {
        "_id": {
          "description": "_id identifies a resource in the OADA API.",
          "type": "string"
        },
        "_rev": {
          "description": "_rev is the revision string for a resource in the OADA API.",
          "type": "integer"
        }
      },
      "required": ["_id", "_rev"],
      "type": "object"
    },
    "_type": {
      "enum": ["application/vnd.oada.harvest.1+json"]
    }
  },
  "additionalProperties": true,
  "required": ["_type"],
  "type": "object",
  "examples": [{
    "_id": "resources/90fijklf3",
    "_rev": 7,
    "_type": "application/vnd.oada.harvest.1+json",
    "context": {},
    "as-harvested": {
      "_id": "resources/resources/kfj20ikejldss",
      "_rev": 9
    },
    "tiled-maps": {
      "_id": "resources/92jfkjfe0fdi",
      "_rev": 8
    }
  }]
};
validate.errors = null;
module.exports = validate;