'use strict';
var formats = require('ajv/lib/compile/formats')();
var validate = (function() {
  var pattern0 = new RegExp('irrigation');
  var refVal = [];
  var refVal1 = (function() {
    var refVal = [];
    var refVal1 = (function() {
      return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
        'use strict';
        var vErrors = null;
        var errors = 0;
        if (rootData === undefined) rootData = data;
        var errs__0 = errors;
        var valid0 = false;
        var errs_1 = errors;
        var errs_2 = errors;
        if ((data && typeof data === "object" && !Array.isArray(data))) {
          if (true) {
            var errs__2 = errors;
            var valid3 = true;
            if (data._id === undefined) {
              valid3 = false;
              var err = {
                keyword: 'required',
                dataPath: (dataPath || '') + "",
                schemaPath: '#/definitions/nonversioned/required',
                params: {
                  missingProperty: '_id'
                },
                message: 'should have required property \'_id\''
              };
              if (vErrors === null) vErrors = [err];
              else vErrors.push(err);
              errors++;
            } else {
              var errs_3 = errors;
              if (typeof data._id !== "string") {
                var err = {
                  keyword: 'type',
                  dataPath: (dataPath || '') + '._id',
                  schemaPath: '#/definitions/nonversioned/properties/_id/type',
                  params: {
                    type: 'string'
                  },
                  message: 'should be string'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
              }
              var valid3 = errors === errs_3;
            }
            if (valid3) {}
            if (errs__2 == errors) {}
          }
        } else {
          var err = {
            keyword: 'type',
            dataPath: (dataPath || '') + "",
            schemaPath: '#/definitions/nonversioned/type',
            params: {
              type: 'object'
            },
            message: 'should be object'
          };
          if (vErrors === null) vErrors = [err];
          else vErrors.push(err);
          errors++;
        }
        if (errors === errs_2) {}
        var valid2 = errors === errs_2;
        if (valid2) {}
        if (errors === errs_1) {}
        var valid1 = errors === errs_1;
        valid0 = valid0 || valid1;
        if (!valid0) {
          var errs_1 = errors;
          if (!refVal3(data, (dataPath || ''), parentData, parentDataProperty, rootData)) {
            if (vErrors === null) vErrors = refVal3.errors;
            else vErrors = vErrors.concat(refVal3.errors);
            errors = vErrors.length;
          } else {}
          if (errors === errs_1) {}
          var valid1 = errors === errs_1;
          valid0 = valid0 || valid1;
          if (!valid0) {}
        }
        if (!valid0) {
          var err = {
            keyword: 'anyOf',
            dataPath: (dataPath || '') + "",
            schemaPath: '#/anyOf',
            params: {},
            message: 'should match some schema in anyOf'
          };
          if (vErrors === null) vErrors = [err];
          else vErrors.push(err);
          errors++;
          validate.errors = vErrors;
          return false;
        } else {
          errors = errs__0;
          if (vErrors !== null) {
            if (errs__0) vErrors.length = errs__0;
            else vErrors = null;
          }
        }
        if (errors === 0) {}
        validate.errors = vErrors;
        return errors === 0;
      };
    })();
    refVal1.schema = {
      "anyOf": [{
        "$ref": "#/definitions/nonversioned"
      }, {
        "$ref": "#/definitions/versioned"
      }]
    };
    refVal1.errors = null;
    refVal[1] = refVal1;
    var refVal2 = {
      "type": "object",
      "required": ["_id"],
      "additionalProperties": true,
      "properties": {
        "_id": {
          "type": "string"
        }
      }
    };
    refVal[2] = refVal2;
    var refVal3 = (function() {
      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;
      };
    })();
    refVal3.schema = {
      "type": "object",
      "required": ["_rev", "_id"],
      "additionalProperties": true,
      "properties": {
        "_id": {
          "type": "string"
        },
        "_rev": {
          "$ref": "../../oada.schema.json#/definitions/_rev"
        }
      }
    };
    refVal3.errors = null;
    refVal[3] = refVal3;
    var refVal4 = {
      "description": "_rev is the revision for a resource in the OADA API.",
      "type": "integer"
    };
    refVal[4] = refVal4;
    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))) {
        var errs__0 = errors;
        var valid1 = true;
        for (var key0 in data) {
          var errs_1 = errors;
          if (!refVal1(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, 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) break;
        }
        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 = {
    "definitions": {
      "versioned": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/definitions/versioned"
        }
      },
      "nonversioned": {
        "type": "object",
        "additionalProperties": {
          "$ref": "#/definitions/nonversioned"
        }
      }
    },
    "type": "object",
    "additionalProperties": {
      "$ref": "#/definitions/link"
    }
  };
  refVal1.errors = null;
  refVal[1] = refVal1;
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
    'use strict'; /*# sourceURL=https://formats.openag.io/oada/irrigation/machines/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.name;
        if (data1 === undefined) {
          valid1 = false;
          validate.errors = [{
            keyword: 'required',
            dataPath: (dataPath || '') + "",
            schemaPath: '#/required',
            params: {
              missingProperty: 'name'
            },
            message: 'should have required property \'name\''
          }];
          return false;
        } else {
          var errs_1 = errors;
          if (typeof data1 === "string") {
            if (!pattern0.test(data1)) {
              validate.errors = [{
                keyword: 'pattern',
                dataPath: (dataPath || '') + '.name',
                schemaPath: '#/properties/name/pattern',
                params: {
                  pattern: 'irrigation'
                },
                message: 'should match pattern "irrigation"'
              }];
              return false;
            } else {}
          } else {
            validate.errors = [{
              keyword: 'type',
              dataPath: (dataPath || '') + '.name',
              schemaPath: '#/properties/name/type',
              params: {
                type: 'string'
              },
              message: 'should be string'
            }];
            return false;
          }
          if (errors === errs_1) {}
          var valid1 = errors === errs_1;
        }
        if (valid1) {
          if (data.list === undefined) {
            valid1 = false;
            validate.errors = [{
              keyword: 'required',
              dataPath: (dataPath || '') + "",
              schemaPath: '#/required',
              params: {
                missingProperty: 'list'
              },
              message: 'should have required property \'list\''
            }];
            return false;
          } else {
            var errs_1 = errors;
            if (!refVal1(data.list, (dataPath || '') + '.list', data, 'list', 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/machines/v1.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "application/vnd.oada.irrigation.machines.1+json",
  "required": ["name", "list"],
  "additionalProperties": true,
  "properties": {
    "name": {
      "type": "string",
      "pattern": "irrigation"
    },
    "list": {
      "$ref": "https://formats.openag.io/oada/link/v1.schema.json#/definitions/list"
    }
  },
  "examples": [{
    "name": "irrigation",
    "list": {
      "dummyrandomthing": {
        "_id": "dummyid123AFG",
        "_rev": "1-dummy02ijfl"
      },
      "klsdfj0982ifjoow": {
        "_id": "df002jfk2ojsl",
        "_rev": "3-jkfd0ijs8zk"
      }
    }
  }]
};
validate.errors = null;
module.exports = validate;