'use strict';
var formats = require('ajv/lib/compile/formats')();
var validate = (function() {
  var pattern0 = new RegExp('^https://.*');
  var refVal = [];
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
    'use strict'; /*# sourceURL=https://formats.openag.io/oada/oada-configuration/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.oada_base_uri;
        if (data1 === undefined) {
          valid1 = false;
          validate.errors = [{
            keyword: 'required',
            dataPath: (dataPath || '') + "",
            schemaPath: '#/required',
            params: {
              missingProperty: 'oada_base_uri'
            },
            message: 'should have required property \'oada_base_uri\''
          }];
          return false;
        } else {
          var errs_1 = errors;
          if (typeof data1 === "string") {
            if (!pattern0.test(data1)) {
              validate.errors = [{
                keyword: 'pattern',
                dataPath: (dataPath || '') + '.oada_base_uri',
                schemaPath: '#/properties/oada_base_uri/pattern',
                params: {
                  pattern: '^https://.*'
                },
                message: 'should match pattern "^https://.*"'
              }];
              return false;
            } else {}
          } else {
            validate.errors = [{
              keyword: 'type',
              dataPath: (dataPath || '') + '.oada_base_uri',
              schemaPath: '#/properties/oada_base_uri/type',
              params: {
                type: 'string'
              },
              message: 'should be string'
            }];
            return false;
          }
          if (errors === errs_1) {}
          var valid1 = errors === errs_1;
        }
        if (valid1) {
          var data1 = data.authorization_endpoint;
          if (data1 === undefined) {
            valid1 = false;
            validate.errors = [{
              keyword: 'required',
              dataPath: (dataPath || '') + "",
              schemaPath: '#/required',
              params: {
                missingProperty: 'authorization_endpoint'
              },
              message: 'should have required property \'authorization_endpoint\''
            }];
            return false;
          } else {
            var errs_1 = errors;
            if (typeof data1 === "string") {
              if (!pattern0.test(data1)) {
                validate.errors = [{
                  keyword: 'pattern',
                  dataPath: (dataPath || '') + '.authorization_endpoint',
                  schemaPath: '#/properties/authorization_endpoint/pattern',
                  params: {
                    pattern: '^https://.*'
                  },
                  message: 'should match pattern "^https://.*"'
                }];
                return false;
              } else {}
            } else {
              validate.errors = [{
                keyword: 'type',
                dataPath: (dataPath || '') + '.authorization_endpoint',
                schemaPath: '#/properties/authorization_endpoint/type',
                params: {
                  type: 'string'
                },
                message: 'should be string'
              }];
              return false;
            }
            if (errors === errs_1) {}
            var valid1 = errors === errs_1;
          }
          if (valid1) {
            var data1 = data.token_endpoint;
            if (data1 === undefined) {
              valid1 = false;
              validate.errors = [{
                keyword: 'required',
                dataPath: (dataPath || '') + "",
                schemaPath: '#/required',
                params: {
                  missingProperty: 'token_endpoint'
                },
                message: 'should have required property \'token_endpoint\''
              }];
              return false;
            } else {
              var errs_1 = errors;
              if (typeof data1 === "string") {
                if (!pattern0.test(data1)) {
                  validate.errors = [{
                    keyword: 'pattern',
                    dataPath: (dataPath || '') + '.token_endpoint',
                    schemaPath: '#/properties/token_endpoint/pattern',
                    params: {
                      pattern: '^https://.*'
                    },
                    message: 'should match pattern "^https://.*"'
                  }];
                  return false;
                } else {}
              } else {
                validate.errors = [{
                  keyword: 'type',
                  dataPath: (dataPath || '') + '.token_endpoint',
                  schemaPath: '#/properties/token_endpoint/type',
                  params: {
                    type: 'string'
                  },
                  message: 'should be string'
                }];
                return false;
              }
              if (errors === errs_1) {}
              var valid1 = errors === errs_1;
            }
            if (valid1) {
              var data1 = data.registration_endpoint;
              if (data1 === undefined) {
                valid1 = false;
                validate.errors = [{
                  keyword: 'required',
                  dataPath: (dataPath || '') + "",
                  schemaPath: '#/required',
                  params: {
                    missingProperty: 'registration_endpoint'
                  },
                  message: 'should have required property \'registration_endpoint\''
                }];
                return false;
              } else {
                var errs_1 = errors;
                if (typeof data1 === "string") {
                  if (!pattern0.test(data1)) {
                    validate.errors = [{
                      keyword: 'pattern',
                      dataPath: (dataPath || '') + '.registration_endpoint',
                      schemaPath: '#/properties/registration_endpoint/pattern',
                      params: {
                        pattern: '^https://.*'
                      },
                      message: 'should match pattern "^https://.*"'
                    }];
                    return false;
                  } else {}
                } else {
                  validate.errors = [{
                    keyword: 'type',
                    dataPath: (dataPath || '') + '.registration_endpoint',
                    schemaPath: '#/properties/registration_endpoint/type',
                    params: {
                      type: 'string'
                    },
                    message: 'should be string'
                  }];
                  return false;
                }
                if (errors === errs_1) {}
                var valid1 = errors === errs_1;
              }
              if (valid1) {
                var data1 = data.token_endpoint_auth_signing_alg_values_supported;
                if (data1 === undefined) {
                  valid1 = false;
                  validate.errors = [{
                    keyword: 'required',
                    dataPath: (dataPath || '') + "",
                    schemaPath: '#/required',
                    params: {
                      missingProperty: 'token_endpoint_auth_signing_alg_values_supported'
                    },
                    message: 'should have required property \'token_endpoint_auth_signing_alg_values_supported\''
                  }];
                  return false;
                } else {
                  var errs_1 = errors;
                  if (Array.isArray(data1)) {
                    if (data1.length < 1) {
                      validate.errors = [{
                        keyword: 'minItems',
                        dataPath: (dataPath || '') + '.token_endpoint_auth_signing_alg_values_supported',
                        schemaPath: '#/properties/token_endpoint_auth_signing_alg_values_supported/minItems',
                        params: {
                          limit: 1
                        },
                        message: 'should NOT have fewer than 1 items'
                      }];
                      return false;
                    } else {
                      var errs__1 = errors;
                      var valid1;
                      for (var i1 = 0; i1 < data1.length; i1++) {
                        var errs_2 = errors;
                        if (typeof data1[i1] !== "string") {
                          validate.errors = [{
                            keyword: 'type',
                            dataPath: (dataPath || '') + '.token_endpoint_auth_signing_alg_values_supported[' + i1 + ']',
                            schemaPath: '#/properties/token_endpoint_auth_signing_alg_values_supported/items/type',
                            params: {
                              type: 'string'
                            },
                            message: 'should be string'
                          }];
                          return false;
                        }
                        var valid2 = errors === errs_2;
                        if (!valid2) break;
                      }
                      if (errs__1 == errors) {
                        var i = data1.length,
                          valid1 = true,
                          j;
                        if (i > 1) {
                          var itemIndices = {},
                            item;
                          for (; i--;) {
                            var item = data1[i];
                            if (typeof item !== "string") continue;
                            if (typeof itemIndices[item] == 'number') {
                              valid1 = false;
                              j = itemIndices[item];
                              break;
                            }
                            itemIndices[item] = i;
                          }
                        }
                        if (!valid1) {
                          validate.errors = [{
                            keyword: 'uniqueItems',
                            dataPath: (dataPath || '') + '.token_endpoint_auth_signing_alg_values_supported',
                            schemaPath: '#/properties/token_endpoint_auth_signing_alg_values_supported/uniqueItems',
                            params: {
                              i: i,
                              j: j
                            },
                            message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)'
                          }];
                          return false;
                        } else {}
                      }
                    }
                  } else {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '.token_endpoint_auth_signing_alg_values_supported',
                      schemaPath: '#/properties/token_endpoint_auth_signing_alg_values_supported/type',
                      params: {
                        type: 'array'
                      },
                      message: 'should be array'
                    }];
                    return false;
                  }
                  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/oada-configuration/v1.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "application/vnd.oada.well-known.oada-configuration.1+json",
  "required": ["oada_base_uri", "authorization_endpoint", "token_endpoint", "registration_endpoint", "token_endpoint_auth_signing_alg_values_supported"],
  "additionalProperties": true,
  "properties": {
    "oada_base_uri": {
      "type": "string",
      "pattern": "^https://.*"
    },
    "authorization_endpoint": {
      "type": "string",
      "pattern": "^https://.*"
    },
    "token_endpoint": {
      "type": "string",
      "pattern": "^https://.*"
    },
    "registration_endpoint": {
      "type": "string",
      "pattern": "^https://.*"
    },
    "token_endpoint_auth_signing_alg_values_supported": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": {
        "type": "string"
      }
    }
  },
  "type": "object",
  "examples": [{
    "well_known_version": "1.0.0",
    "oada_base_uri": "https://oada.example.com",
    "authorization_endpoint": "https://oada.example.com/auth",
    "token_endpoint": "https://oada.example.com/token",
    "registration_endpoint": "https://oada.example.com/register",
    "token_endpoint_auth_signing_alg_values_supported": ["RS256"],
    "scopes_supported": [{
      "name": "oada.all.1",
      "read+write": true
    }]
  }]
};
validate.errors = null;
module.exports = validate;