'use strict';
var formats = require('ajv/lib/compile/formats')();
var validate = (function() {
  var refVal = [];
  var refVal1 = (function() {
    var refVal = [];
    var refVal1 = {
      "description": "_rev is the revision for a resource in the OADA API.",
      "type": "integer"
    };
    refVal[1] = refVal1;
    return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
      'use strict';
      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;
          if (data._id === undefined) {
            valid1 = false;
            validate.errors = [{
              keyword: 'required',
              dataPath: (dataPath || '') + "",
              schemaPath: '#/required',
              params: {
                missingProperty: '_id'
              },
              message: 'should have required property \'_id\''
            }];
            return false;
          } 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 = false;
              validate.errors = [{
                keyword: 'required',
                dataPath: (dataPath || '') + "",
                schemaPath: '#/required',
                params: {
                  missingProperty: '_rev'
                },
                message: 'should have required property \'_rev\''
              }];
              return false;
            } else {
              var errs_1 = errors;
              var errs_2 = errors;
              if ((typeof data1 !== "number" || (data1 % 1) || data1 !== data1)) {
                validate.errors = [{
                  keyword: 'type',
                  dataPath: (dataPath || '') + '._rev',
                  schemaPath: '../../oada.schema.json#/definitions/_rev/type',
                  params: {
                    type: 'integer'
                  },
                  message: 'should be integer'
                }];
                return false;
              }
              var valid2 = errors === errs_2;
              if (valid2) {}
              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;
    };
  })();
  refVal1.schema = {
    "type": "object",
    "required": ["_rev", "_id"],
    "additionalProperties": true,
    "properties": {
      "_id": {
        "type": "string"
      },
      "_rev": {
        "$ref": "../../oada.schema.json#/definitions/_rev"
      }
    }
  };
  refVal1.errors = null;
  refVal[1] = refVal1;
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
    'use strict'; /*# sourceURL=https://formats.openag.io/oada/irrigation/v1.schema.json */
    var vErrors = null;
    var errors = 0;
    if (rootData === undefined) rootData = data;
    if ((data && typeof data === "object" && !Array.isArray(data))) {
      var errs__0 = errors;
      var valid1 = true;
      if (data.machines === undefined) {
        valid1 = true;
      } else {
        var errs_1 = errors;
        if (!refVal1(data.machines, (dataPath || '') + '.machines', data, 'machines', rootData)) {
          if (vErrors === null) vErrors = refVal1.errors;
          else vErrors = vErrors.concat(refVal1.errors);
          errors = vErrors.length;
        } else {}
        if (errors === errs_1) {}
        var valid1 = errors === errs_1;
      }
      if (valid1) {}
      if (errs__0 == errors) {}
    }
    if (errors === 0) {}
    validate.errors = vErrors;
    return errors === 0;
  };
})();
validate.schema = {
  "$id": "https://formats.openag.io/oada/irrigation/v1.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "application/vnd.oada.irrigation.1+json",
  "additionalProperties": true,
  "properties": {
    "machines": {
      "$ref": "https://formats.openag.io/oada/link/v1.schema.json#/definitions/versioned"
    }
  },
  "examples": [{
    "machines": {
      "_id": "dummyid123AFG",
      "_rev": "1-dummy02ijfl"
    }
  }]
};
validate.errors = null;
module.exports = validate;