'use strict';
var formats = require('ajv/lib/compile/formats')();
var ucs2length = require('ajv/lib/compile/ucs2length');
var equal = require('ajv/lib/compile/equal');
var validate = (function() {
  var refVal = [];
  var refVal1 = {
    "$comment": "TODO: Allow emails like: 'John Doe <john@example.org>'",
    "description": "Object for email and associated person's name",
    "oneOf": [{
      "type": "string",
      "format": "email"
    }, {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email"
        },
        "name": {
          "type": "string"
        }
      },
      "required": ["email"]
    }]
  };
  refVal[1] = refVal1;
  var refVal2 = (function() {
    var pattern0 = new RegExp('^resources/.*$');
    var refVal = [];
    var refVal1 = (function() {
      var pattern0 = new RegExp('^resources/.*$');
      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;
            for (var key0 in data) {
              var isAdditional0 = !(false || key0 == '_rev' || key0 == '_id' || key0 == '_type');
              if (isAdditional0) {
                valid1 = false;
                validate.errors = [{
                  keyword: 'additionalProperties',
                  dataPath: (dataPath || '') + "",
                  schemaPath: '#/additionalProperties',
                  params: {
                    additionalProperty: '' + key0 + ''
                  },
                  message: 'should NOT have additional properties'
                }];
                return false;
                break;
              }
            }
            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: '#/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) {
                var data1 = data._id;
                if (data1 === undefined) {
                  valid1 = true;
                } else {
                  var errs_1 = errors;
                  var errs_2 = errors;
                  if (typeof data1 === "string") {
                    if (!pattern0.test(data1)) {
                      validate.errors = [{
                        keyword: 'pattern',
                        dataPath: (dataPath || '') + '._id',
                        schemaPath: '#/definitions/_id/pattern',
                        params: {
                          pattern: '^resources/.*$'
                        },
                        message: 'should match pattern "^resources/.*$"'
                      }];
                      return false;
                    } else {}
                  } else {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '._id',
                      schemaPath: '#/definitions/_id/type',
                      params: {
                        type: 'string'
                      },
                      message: 'should be string'
                    }];
                    return false;
                  }
                  if (errors === errs_2) {}
                  var valid2 = errors === errs_2;
                  if (valid2) {}
                  if (errors === errs_1) {}
                  var valid1 = errors === errs_1;
                }
                if (valid1) {
                  if (data._type === undefined) {
                    valid1 = true;
                  } else {
                    var errs_1 = errors;
                    var errs_2 = errors;
                    if (typeof data._type !== "string") {
                      validate.errors = [{
                        keyword: 'type',
                        dataPath: (dataPath || '') + '._type',
                        schemaPath: '#/definitions/_type/type',
                        params: {
                          type: 'string'
                        },
                        message: 'should be string'
                      }];
                      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 = {
      "$anchor": "versioned",
      "type": "object",
      "required": ["_rev"],
      "properties": {
        "_rev": {
          "$ref": "#/definitions/_rev"
        },
        "_id": {
          "$ref": "#/definitions/_id"
        },
        "_type": {
          "$ref": "#/definitions/_type"
        }
      },
      "additionalProperties": false
    };
    refVal1.errors = null;
    refVal[1] = refVal1;
    var refVal2 = {
      "description": "_rev is the revision for a resource in the OADA API.",
      "type": "integer"
    };
    refVal[2] = refVal2;
    var refVal3 = {
      "description": "_id identifies a resource in the OADA API.",
      "type": "string",
      "pattern": "^resources/.*$"
    };
    refVal[3] = refVal3;
    var refVal4 = {
      "description": "_type identifies the content-type of a resource in the OADA API and             is required for all OADA-defined formats.  It usually looks like            application/vnd.oada.something.1+json.",
      "type": "string"
    };
    refVal[4] = refVal4;
    var refVal5 = (function() {
      var pattern0 = new RegExp('^resources/.*$');
      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;
            for (var key0 in data) {
              var isAdditional0 = !(false || key0 == '_id' || key0 == '_type');
              if (isAdditional0) {
                valid1 = false;
                validate.errors = [{
                  keyword: 'additionalProperties',
                  dataPath: (dataPath || '') + "",
                  schemaPath: '#/additionalProperties',
                  params: {
                    additionalProperty: '' + key0 + ''
                  },
                  message: 'should NOT have additional properties'
                }];
                return false;
                break;
              }
            }
            if (valid1) {
              var data1 = data._id;
              if (data1 === 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;
                var errs_2 = errors;
                if (typeof data1 === "string") {
                  if (!pattern0.test(data1)) {
                    validate.errors = [{
                      keyword: 'pattern',
                      dataPath: (dataPath || '') + '._id',
                      schemaPath: '#/definitions/_id/pattern',
                      params: {
                        pattern: '^resources/.*$'
                      },
                      message: 'should match pattern "^resources/.*$"'
                    }];
                    return false;
                  } else {}
                } else {
                  validate.errors = [{
                    keyword: 'type',
                    dataPath: (dataPath || '') + '._id',
                    schemaPath: '#/definitions/_id/type',
                    params: {
                      type: 'string'
                    },
                    message: 'should be string'
                  }];
                  return false;
                }
                if (errors === errs_2) {}
                var valid2 = errors === errs_2;
                if (valid2) {}
                if (errors === errs_1) {}
                var valid1 = errors === errs_1;
              }
              if (valid1) {
                if (data._type === undefined) {
                  valid1 = true;
                } else {
                  var errs_1 = errors;
                  var errs_2 = errors;
                  if (typeof data._type !== "string") {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '._type',
                      schemaPath: '#/definitions/_type/type',
                      params: {
                        type: 'string'
                      },
                      message: 'should be string'
                    }];
                    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;
      };
    })();
    refVal5.schema = {
      "$anchor": "unversioned",
      "type": "object",
      "required": ["_id"],
      "properties": {
        "_id": {
          "$ref": "#/definitions/_id"
        },
        "_type": {
          "$ref": "#/definitions/_type"
        }
      },
      "additionalProperties": false
    };
    refVal5.errors = null;
    refVal[5] = refVal5;
    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;
      if (!refVal1(data, (dataPath || ''), parentData, parentDataProperty, 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;
      valid0 = valid0 || valid1;
      if (!valid0) {
        var errs_1 = errors;
        if (!refVal5(data, (dataPath || ''), parentData, parentDataProperty, rootData)) {
          if (vErrors === null) vErrors = refVal5.errors;
          else vErrors = vErrors.concat(refVal5.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;
    };
  })();
  refVal2.schema = {
    "$anchor": "link",
    "definitions": {
      "versioned": {
        "$anchor": "versioned",
        "type": "object",
        "required": ["_rev"],
        "properties": {
          "_rev": {
            "$ref": "#/definitions/_rev"
          },
          "_id": {
            "$ref": "#/definitions/_id"
          },
          "_type": {
            "$ref": "#/definitions/_type"
          }
        },
        "additionalProperties": false
      },
      "unversioned": {
        "$anchor": "unversioned",
        "type": "object",
        "required": ["_id"],
        "properties": {
          "_id": {
            "$ref": "#/definitions/_id"
          },
          "_type": {
            "$ref": "#/definitions/_type"
          }
        },
        "additionalProperties": false
      }
    },
    "anyOf": [{
      "$ref": "#/definitions/link/definitions/versioned"
    }, {
      "$ref": "#/definitions/link/definitions/unversioned"
    }]
  };
  refVal2.errors = null;
  refVal[2] = refVal2;
  return function validate(data, dataPath, parentData, parentDataProperty, rootData) {
    'use strict'; /*# sourceURL=https://formats.openag.io/trellis/service/abalonemail/config/email.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;
        if (data.multiple === undefined) {
          valid1 = true;
        } else {
          var errs_1 = errors;
          if (typeof data.multiple !== "boolean") {
            validate.errors = [{
              keyword: 'type',
              dataPath: (dataPath || '') + '.multiple',
              schemaPath: '#/properties/multiple/type',
              params: {
                type: 'boolean'
              },
              message: 'should be boolean'
            }];
            return false;
          }
          var valid1 = errors === errs_1;
        }
        if (valid1) {
          var data1 = data.from;
          if (data1 === undefined) {
            valid1 = false;
            validate.errors = [{
              keyword: 'required',
              dataPath: (dataPath || '') + "",
              schemaPath: '#/required',
              params: {
                missingProperty: 'from'
              },
              message: 'should have required property \'from\''
            }];
            return false;
          } else {
            var errs_1 = errors;
            var errs_2 = errors;
            var errs__2 = errors,
              prevValid2 = false,
              valid2 = false,
              passingSchemas2 = null;
            var errs_3 = errors;
            if ((typeof data1 === "number")) {
              if (true) {}
            }
            if (errors === errs_3) {
              if (typeof data1 === "string") {
                if (!formats.email.test(data1)) {
                  var err = {
                    keyword: 'format',
                    dataPath: (dataPath || '') + '.from',
                    schemaPath: '#/definitions/email/oneOf/0/format',
                    params: {
                      format: 'email'
                    },
                    message: 'should match format "email"'
                  };
                  if (vErrors === null) vErrors = [err];
                  else vErrors.push(err);
                  errors++;
                } else {}
              } else {
                var err = {
                  keyword: 'type',
                  dataPath: (dataPath || '') + '.from',
                  schemaPath: '#/definitions/email/oneOf/0/type',
                  params: {
                    type: 'string'
                  },
                  message: 'should be string'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
              }
              if (errors === errs_3) {}
            }
            var valid3 = errors === errs_3;
            if (valid3) {
              valid2 = prevValid2 = true;
              passingSchemas2 = 0;
            }
            var errs_3 = errors;
            if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
              if (true) {
                var errs__3 = errors;
                var valid4 = true;
                var data2 = data1.email;
                if (data2 === undefined) {
                  valid4 = false;
                  var err = {
                    keyword: 'required',
                    dataPath: (dataPath || '') + '.from',
                    schemaPath: '#/definitions/email/oneOf/1/required',
                    params: {
                      missingProperty: 'email'
                    },
                    message: 'should have required property \'email\''
                  };
                  if (vErrors === null) vErrors = [err];
                  else vErrors.push(err);
                  errors++;
                } else {
                  var errs_4 = errors;
                  if ((typeof data2 === "number")) {
                    if (true) {}
                  }
                  if (errors === errs_4) {
                    if (typeof data2 === "string") {
                      if (!formats.email.test(data2)) {
                        var err = {
                          keyword: 'format',
                          dataPath: (dataPath || '') + '.from.email',
                          schemaPath: '#/definitions/email/oneOf/1/properties/email/format',
                          params: {
                            format: 'email'
                          },
                          message: 'should match format "email"'
                        };
                        if (vErrors === null) vErrors = [err];
                        else vErrors.push(err);
                        errors++;
                      } else {}
                    } else {
                      var err = {
                        keyword: 'type',
                        dataPath: (dataPath || '') + '.from.email',
                        schemaPath: '#/definitions/email/oneOf/1/properties/email/type',
                        params: {
                          type: 'string'
                        },
                        message: 'should be string'
                      };
                      if (vErrors === null) vErrors = [err];
                      else vErrors.push(err);
                      errors++;
                    }
                    if (errors === errs_4) {}
                  }
                  var valid4 = errors === errs_4;
                }
                if (valid4) {
                  if (data1.name === undefined) {
                    valid4 = true;
                  } else {
                    var errs_4 = errors;
                    if (typeof data1.name !== "string") {
                      var err = {
                        keyword: 'type',
                        dataPath: (dataPath || '') + '.from.name',
                        schemaPath: '#/definitions/email/oneOf/1/properties/name/type',
                        params: {
                          type: 'string'
                        },
                        message: 'should be string'
                      };
                      if (vErrors === null) vErrors = [err];
                      else vErrors.push(err);
                      errors++;
                    }
                    var valid4 = errors === errs_4;
                  }
                  if (valid4) {}
                }
                if (errs__3 == errors) {}
              }
            } else {
              var err = {
                keyword: 'type',
                dataPath: (dataPath || '') + '.from',
                schemaPath: '#/definitions/email/oneOf/1/type',
                params: {
                  type: 'object'
                },
                message: 'should be object'
              };
              if (vErrors === null) vErrors = [err];
              else vErrors.push(err);
              errors++;
            }
            if (errors === errs_3) {}
            var valid3 = errors === errs_3;
            if (valid3 && prevValid2) {
              valid2 = false;
              passingSchemas2 = [passingSchemas2, 1];
            } else {
              if (valid3) {
                valid2 = prevValid2 = true;
                passingSchemas2 = 1;
              }
            }
            if (!valid2) {
              var err = {
                keyword: 'oneOf',
                dataPath: (dataPath || '') + '.from',
                schemaPath: '#/definitions/email/oneOf',
                params: {
                  passingSchemas: passingSchemas2
                },
                message: 'should match exactly one schema in oneOf'
              };
              if (vErrors === null) vErrors = [err];
              else vErrors.push(err);
              errors++;
              validate.errors = vErrors;
              return false;
            } else {
              errors = errs__2;
              if (vErrors !== null) {
                if (errs__2) vErrors.length = errs__2;
                else vErrors = null;
              }
            }
            if (errors === errs_2) {}
            var valid2 = errors === errs_2;
            if (valid2) {}
            if (errors === errs_1) {}
            var valid1 = errors === errs_1;
          }
          if (valid1) {
            var data1 = data.to;
            if (data1 === undefined) {
              valid1 = false;
              validate.errors = [{
                keyword: 'required',
                dataPath: (dataPath || '') + "",
                schemaPath: '#/required',
                params: {
                  missingProperty: 'to'
                },
                message: 'should have required property \'to\''
              }];
              return false;
            } else {
              var errs_1 = errors;
              var errs__1 = errors,
                prevValid1 = false,
                valid1 = false,
                passingSchemas1 = null;
              var errs_2 = errors;
              var errs_3 = errors;
              var errs__3 = errors,
                prevValid3 = false,
                valid3 = false,
                passingSchemas3 = null;
              var errs_4 = errors;
              if ((typeof data1 === "number")) {
                if (true) {}
              }
              if (errors === errs_4) {
                if (typeof data1 === "string") {
                  if (!formats.email.test(data1)) {
                    var err = {
                      keyword: 'format',
                      dataPath: (dataPath || '') + '.to',
                      schemaPath: '#/definitions/email/oneOf/0/format',
                      params: {
                        format: 'email'
                      },
                      message: 'should match format "email"'
                    };
                    if (vErrors === null) vErrors = [err];
                    else vErrors.push(err);
                    errors++;
                  } else {}
                } else {
                  var err = {
                    keyword: 'type',
                    dataPath: (dataPath || '') + '.to',
                    schemaPath: '#/definitions/email/oneOf/0/type',
                    params: {
                      type: 'string'
                    },
                    message: 'should be string'
                  };
                  if (vErrors === null) vErrors = [err];
                  else vErrors.push(err);
                  errors++;
                }
                if (errors === errs_4) {}
              }
              var valid4 = errors === errs_4;
              if (valid4) {
                valid3 = prevValid3 = true;
                passingSchemas3 = 0;
              }
              var errs_4 = errors;
              if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
                if (true) {
                  var errs__4 = errors;
                  var valid5 = true;
                  var data2 = data1.email;
                  if (data2 === undefined) {
                    valid5 = false;
                    var err = {
                      keyword: 'required',
                      dataPath: (dataPath || '') + '.to',
                      schemaPath: '#/definitions/email/oneOf/1/required',
                      params: {
                        missingProperty: 'email'
                      },
                      message: 'should have required property \'email\''
                    };
                    if (vErrors === null) vErrors = [err];
                    else vErrors.push(err);
                    errors++;
                  } else {
                    var errs_5 = errors;
                    if ((typeof data2 === "number")) {
                      if (true) {}
                    }
                    if (errors === errs_5) {
                      if (typeof data2 === "string") {
                        if (!formats.email.test(data2)) {
                          var err = {
                            keyword: 'format',
                            dataPath: (dataPath || '') + '.to.email',
                            schemaPath: '#/definitions/email/oneOf/1/properties/email/format',
                            params: {
                              format: 'email'
                            },
                            message: 'should match format "email"'
                          };
                          if (vErrors === null) vErrors = [err];
                          else vErrors.push(err);
                          errors++;
                        } else {}
                      } else {
                        var err = {
                          keyword: 'type',
                          dataPath: (dataPath || '') + '.to.email',
                          schemaPath: '#/definitions/email/oneOf/1/properties/email/type',
                          params: {
                            type: 'string'
                          },
                          message: 'should be string'
                        };
                        if (vErrors === null) vErrors = [err];
                        else vErrors.push(err);
                        errors++;
                      }
                      if (errors === errs_5) {}
                    }
                    var valid5 = errors === errs_5;
                  }
                  if (valid5) {
                    if (data1.name === undefined) {
                      valid5 = true;
                    } else {
                      var errs_5 = errors;
                      if (typeof data1.name !== "string") {
                        var err = {
                          keyword: 'type',
                          dataPath: (dataPath || '') + '.to.name',
                          schemaPath: '#/definitions/email/oneOf/1/properties/name/type',
                          params: {
                            type: 'string'
                          },
                          message: 'should be string'
                        };
                        if (vErrors === null) vErrors = [err];
                        else vErrors.push(err);
                        errors++;
                      }
                      var valid5 = errors === errs_5;
                    }
                    if (valid5) {}
                  }
                  if (errs__4 == errors) {}
                }
              } else {
                var err = {
                  keyword: 'type',
                  dataPath: (dataPath || '') + '.to',
                  schemaPath: '#/definitions/email/oneOf/1/type',
                  params: {
                    type: 'object'
                  },
                  message: 'should be object'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
              }
              if (errors === errs_4) {}
              var valid4 = errors === errs_4;
              if (valid4 && prevValid3) {
                valid3 = false;
                passingSchemas3 = [passingSchemas3, 1];
              } else {
                if (valid4) {
                  valid3 = prevValid3 = true;
                  passingSchemas3 = 1;
                }
              }
              if (!valid3) {
                var err = {
                  keyword: 'oneOf',
                  dataPath: (dataPath || '') + '.to',
                  schemaPath: '#/definitions/email/oneOf',
                  params: {
                    passingSchemas: passingSchemas3
                  },
                  message: 'should match exactly one schema in oneOf'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
              } else {
                errors = errs__3;
                if (vErrors !== null) {
                  if (errs__3) vErrors.length = errs__3;
                  else vErrors = null;
                }
              }
              if (errors === errs_3) {}
              var valid3 = errors === errs_3;
              if (valid3) {}
              if (errors === errs_2) {}
              var valid2 = errors === errs_2;
              if (valid2) {
                valid1 = prevValid1 = true;
                passingSchemas1 = 0;
              }
              var errs_2 = errors;
              if (Array.isArray(data1)) {
                var errs__2 = errors;
                var valid2;
                for (var i2 = 0; i2 < data1.length; i2++) {
                  var data2 = data1[i2];
                  var errs_3 = errors;
                  var errs_4 = errors;
                  var errs__4 = errors,
                    prevValid4 = false,
                    valid4 = false,
                    passingSchemas4 = null;
                  var errs_5 = errors;
                  if ((typeof data2 === "number")) {
                    if (true) {}
                  }
                  if (errors === errs_5) {
                    if (typeof data2 === "string") {
                      if (!formats.email.test(data2)) {
                        var err = {
                          keyword: 'format',
                          dataPath: (dataPath || '') + '.to[' + i2 + ']',
                          schemaPath: '#/definitions/email/oneOf/0/format',
                          params: {
                            format: 'email'
                          },
                          message: 'should match format "email"'
                        };
                        if (vErrors === null) vErrors = [err];
                        else vErrors.push(err);
                        errors++;
                      } else {}
                    } else {
                      var err = {
                        keyword: 'type',
                        dataPath: (dataPath || '') + '.to[' + i2 + ']',
                        schemaPath: '#/definitions/email/oneOf/0/type',
                        params: {
                          type: 'string'
                        },
                        message: 'should be string'
                      };
                      if (vErrors === null) vErrors = [err];
                      else vErrors.push(err);
                      errors++;
                    }
                    if (errors === errs_5) {}
                  }
                  var valid5 = errors === errs_5;
                  if (valid5) {
                    valid4 = prevValid4 = true;
                    passingSchemas4 = 0;
                  }
                  var errs_5 = errors;
                  if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
                    if (true) {
                      var errs__5 = errors;
                      var valid6 = true;
                      var data3 = data2.email;
                      if (data3 === undefined) {
                        valid6 = false;
                        var err = {
                          keyword: 'required',
                          dataPath: (dataPath || '') + '.to[' + i2 + ']',
                          schemaPath: '#/definitions/email/oneOf/1/required',
                          params: {
                            missingProperty: 'email'
                          },
                          message: 'should have required property \'email\''
                        };
                        if (vErrors === null) vErrors = [err];
                        else vErrors.push(err);
                        errors++;
                      } else {
                        var errs_6 = errors;
                        if ((typeof data3 === "number")) {
                          if (true) {}
                        }
                        if (errors === errs_6) {
                          if (typeof data3 === "string") {
                            if (!formats.email.test(data3)) {
                              var err = {
                                keyword: 'format',
                                dataPath: (dataPath || '') + '.to[' + i2 + '].email',
                                schemaPath: '#/definitions/email/oneOf/1/properties/email/format',
                                params: {
                                  format: 'email'
                                },
                                message: 'should match format "email"'
                              };
                              if (vErrors === null) vErrors = [err];
                              else vErrors.push(err);
                              errors++;
                            } else {}
                          } else {
                            var err = {
                              keyword: 'type',
                              dataPath: (dataPath || '') + '.to[' + i2 + '].email',
                              schemaPath: '#/definitions/email/oneOf/1/properties/email/type',
                              params: {
                                type: 'string'
                              },
                              message: 'should be string'
                            };
                            if (vErrors === null) vErrors = [err];
                            else vErrors.push(err);
                            errors++;
                          }
                          if (errors === errs_6) {}
                        }
                        var valid6 = errors === errs_6;
                      }
                      if (valid6) {
                        if (data2.name === undefined) {
                          valid6 = true;
                        } else {
                          var errs_6 = errors;
                          if (typeof data2.name !== "string") {
                            var err = {
                              keyword: 'type',
                              dataPath: (dataPath || '') + '.to[' + i2 + '].name',
                              schemaPath: '#/definitions/email/oneOf/1/properties/name/type',
                              params: {
                                type: 'string'
                              },
                              message: 'should be string'
                            };
                            if (vErrors === null) vErrors = [err];
                            else vErrors.push(err);
                            errors++;
                          }
                          var valid6 = errors === errs_6;
                        }
                        if (valid6) {}
                      }
                      if (errs__5 == errors) {}
                    }
                  } else {
                    var err = {
                      keyword: 'type',
                      dataPath: (dataPath || '') + '.to[' + i2 + ']',
                      schemaPath: '#/definitions/email/oneOf/1/type',
                      params: {
                        type: 'object'
                      },
                      message: 'should be object'
                    };
                    if (vErrors === null) vErrors = [err];
                    else vErrors.push(err);
                    errors++;
                  }
                  if (errors === errs_5) {}
                  var valid5 = errors === errs_5;
                  if (valid5 && prevValid4) {
                    valid4 = false;
                    passingSchemas4 = [passingSchemas4, 1];
                  } else {
                    if (valid5) {
                      valid4 = prevValid4 = true;
                      passingSchemas4 = 1;
                    }
                  }
                  if (!valid4) {
                    var err = {
                      keyword: 'oneOf',
                      dataPath: (dataPath || '') + '.to[' + i2 + ']',
                      schemaPath: '#/definitions/email/oneOf',
                      params: {
                        passingSchemas: passingSchemas4
                      },
                      message: 'should match exactly one schema in oneOf'
                    };
                    if (vErrors === null) vErrors = [err];
                    else vErrors.push(err);
                    errors++;
                  } else {
                    errors = errs__4;
                    if (vErrors !== null) {
                      if (errs__4) vErrors.length = errs__4;
                      else vErrors = null;
                    }
                  }
                  if (errors === errs_4) {}
                  var valid4 = errors === errs_4;
                  if (valid4) {}
                  if (errors === errs_3) {}
                  var valid3 = errors === errs_3;
                  if (!valid3) break;
                }
                if (errs__2 == errors) {}
              } else {
                var err = {
                  keyword: 'type',
                  dataPath: (dataPath || '') + '.to',
                  schemaPath: '#/properties/to/oneOf/1/type',
                  params: {
                    type: 'array'
                  },
                  message: 'should be array'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
              }
              if (errors === errs_2) {}
              var valid2 = errors === errs_2;
              if (valid2 && prevValid1) {
                valid1 = false;
                passingSchemas1 = [passingSchemas1, 1];
              } else {
                if (valid2) {
                  valid1 = prevValid1 = true;
                  passingSchemas1 = 1;
                }
              }
              if (!valid1) {
                var err = {
                  keyword: 'oneOf',
                  dataPath: (dataPath || '') + '.to',
                  schemaPath: '#/properties/to/oneOf',
                  params: {
                    passingSchemas: passingSchemas1
                  },
                  message: 'should match exactly one schema in oneOf'
                };
                if (vErrors === null) vErrors = [err];
                else vErrors.push(err);
                errors++;
                validate.errors = vErrors;
                return false;
              } else {
                errors = errs__1;
                if (vErrors !== null) {
                  if (errs__1) vErrors.length = errs__1;
                  else vErrors = null;
                }
              }
              if (errors === errs_1) {}
              var valid1 = errors === errs_1;
            }
            if (valid1) {
              var data1 = data.replyTo;
              if (data1 === undefined) {
                valid1 = true;
              } else {
                var errs_1 = errors;
                var errs_2 = errors;
                var errs__2 = errors,
                  prevValid2 = false,
                  valid2 = false,
                  passingSchemas2 = null;
                var errs_3 = errors;
                if ((typeof data1 === "number")) {
                  if (true) {}
                }
                if (errors === errs_3) {
                  if (typeof data1 === "string") {
                    if (!formats.email.test(data1)) {
                      var err = {
                        keyword: 'format',
                        dataPath: (dataPath || '') + '.replyTo',
                        schemaPath: '#/definitions/email/oneOf/0/format',
                        params: {
                          format: 'email'
                        },
                        message: 'should match format "email"'
                      };
                      if (vErrors === null) vErrors = [err];
                      else vErrors.push(err);
                      errors++;
                    } else {}
                  } else {
                    var err = {
                      keyword: 'type',
                      dataPath: (dataPath || '') + '.replyTo',
                      schemaPath: '#/definitions/email/oneOf/0/type',
                      params: {
                        type: 'string'
                      },
                      message: 'should be string'
                    };
                    if (vErrors === null) vErrors = [err];
                    else vErrors.push(err);
                    errors++;
                  }
                  if (errors === errs_3) {}
                }
                var valid3 = errors === errs_3;
                if (valid3) {
                  valid2 = prevValid2 = true;
                  passingSchemas2 = 0;
                }
                var errs_3 = errors;
                if ((data1 && typeof data1 === "object" && !Array.isArray(data1))) {
                  if (true) {
                    var errs__3 = errors;
                    var valid4 = true;
                    var data2 = data1.email;
                    if (data2 === undefined) {
                      valid4 = false;
                      var err = {
                        keyword: 'required',
                        dataPath: (dataPath || '') + '.replyTo',
                        schemaPath: '#/definitions/email/oneOf/1/required',
                        params: {
                          missingProperty: 'email'
                        },
                        message: 'should have required property \'email\''
                      };
                      if (vErrors === null) vErrors = [err];
                      else vErrors.push(err);
                      errors++;
                    } else {
                      var errs_4 = errors;
                      if ((typeof data2 === "number")) {
                        if (true) {}
                      }
                      if (errors === errs_4) {
                        if (typeof data2 === "string") {
                          if (!formats.email.test(data2)) {
                            var err = {
                              keyword: 'format',
                              dataPath: (dataPath || '') + '.replyTo.email',
                              schemaPath: '#/definitions/email/oneOf/1/properties/email/format',
                              params: {
                                format: 'email'
                              },
                              message: 'should match format "email"'
                            };
                            if (vErrors === null) vErrors = [err];
                            else vErrors.push(err);
                            errors++;
                          } else {}
                        } else {
                          var err = {
                            keyword: 'type',
                            dataPath: (dataPath || '') + '.replyTo.email',
                            schemaPath: '#/definitions/email/oneOf/1/properties/email/type',
                            params: {
                              type: 'string'
                            },
                            message: 'should be string'
                          };
                          if (vErrors === null) vErrors = [err];
                          else vErrors.push(err);
                          errors++;
                        }
                        if (errors === errs_4) {}
                      }
                      var valid4 = errors === errs_4;
                    }
                    if (valid4) {
                      if (data1.name === undefined) {
                        valid4 = true;
                      } else {
                        var errs_4 = errors;
                        if (typeof data1.name !== "string") {
                          var err = {
                            keyword: 'type',
                            dataPath: (dataPath || '') + '.replyTo.name',
                            schemaPath: '#/definitions/email/oneOf/1/properties/name/type',
                            params: {
                              type: 'string'
                            },
                            message: 'should be string'
                          };
                          if (vErrors === null) vErrors = [err];
                          else vErrors.push(err);
                          errors++;
                        }
                        var valid4 = errors === errs_4;
                      }
                      if (valid4) {}
                    }
                    if (errs__3 == errors) {}
                  }
                } else {
                  var err = {
                    keyword: 'type',
                    dataPath: (dataPath || '') + '.replyTo',
                    schemaPath: '#/definitions/email/oneOf/1/type',
                    params: {
                      type: 'object'
                    },
                    message: 'should be object'
                  };
                  if (vErrors === null) vErrors = [err];
                  else vErrors.push(err);
                  errors++;
                }
                if (errors === errs_3) {}
                var valid3 = errors === errs_3;
                if (valid3 && prevValid2) {
                  valid2 = false;
                  passingSchemas2 = [passingSchemas2, 1];
                } else {
                  if (valid3) {
                    valid2 = prevValid2 = true;
                    passingSchemas2 = 1;
                  }
                }
                if (!valid2) {
                  var err = {
                    keyword: 'oneOf',
                    dataPath: (dataPath || '') + '.replyTo',
                    schemaPath: '#/definitions/email/oneOf',
                    params: {
                      passingSchemas: passingSchemas2
                    },
                    message: 'should match exactly one schema in oneOf'
                  };
                  if (vErrors === null) vErrors = [err];
                  else vErrors.push(err);
                  errors++;
                  validate.errors = vErrors;
                  return false;
                } else {
                  errors = errs__2;
                  if (vErrors !== null) {
                    if (errs__2) vErrors.length = errs__2;
                    else vErrors = null;
                  }
                }
                if (errors === errs_2) {}
                var valid2 = errors === errs_2;
                if (valid2) {}
                if (errors === errs_1) {}
                var valid1 = errors === errs_1;
              }
              if (valid1) {
                var data1 = data.subject;
                if (data1 === undefined) {
                  valid1 = true;
                } else {
                  var errs_1 = errors;
                  if (typeof data1 === "string") {
                    if (ucs2length(data1) < 1) {
                      validate.errors = [{
                        keyword: 'minLength',
                        dataPath: (dataPath || '') + '.subject',
                        schemaPath: '#/properties/subject/minLength',
                        params: {
                          limit: 1
                        },
                        message: 'should NOT be shorter than 1 characters'
                      }];
                      return false;
                    } else {}
                  } else {
                    validate.errors = [{
                      keyword: 'type',
                      dataPath: (dataPath || '') + '.subject',
                      schemaPath: '#/properties/subject/type',
                      params: {
                        type: 'string'
                      },
                      message: 'should be string'
                    }];
                    return false;
                  }
                  if (errors === errs_1) {}
                  var valid1 = errors === errs_1;
                }
                if (valid1) {
                  var data1 = data.text;
                  if (data1 === undefined) {
                    valid1 = true;
                  } else {
                    var errs_1 = errors;
                    if (typeof data1 === "string") {
                      if (ucs2length(data1) < 1) {
                        validate.errors = [{
                          keyword: 'minLength',
                          dataPath: (dataPath || '') + '.text',
                          schemaPath: '#/properties/text/minLength',
                          params: {
                            limit: 1
                          },
                          message: 'should NOT be shorter than 1 characters'
                        }];
                        return false;
                      } else {}
                    } else {
                      validate.errors = [{
                        keyword: 'type',
                        dataPath: (dataPath || '') + '.text',
                        schemaPath: '#/properties/text/type',
                        params: {
                          type: 'string'
                        },
                        message: 'should be string'
                      }];
                      return false;
                    }
                    if (errors === errs_1) {}
                    var valid1 = errors === errs_1;
                  }
                  if (valid1) {
                    var data1 = data.html;
                    if (data1 === undefined) {
                      valid1 = true;
                    } else {
                      var errs_1 = errors;
                      if (typeof data1 === "string") {
                        if (ucs2length(data1) < 1) {
                          validate.errors = [{
                            keyword: 'minLength',
                            dataPath: (dataPath || '') + '.html',
                            schemaPath: '#/properties/html/minLength',
                            params: {
                              limit: 1
                            },
                            message: 'should NOT be shorter than 1 characters'
                          }];
                          return false;
                        } else {}
                      } else {
                        validate.errors = [{
                          keyword: 'type',
                          dataPath: (dataPath || '') + '.html',
                          schemaPath: '#/properties/html/type',
                          params: {
                            type: 'string'
                          },
                          message: 'should be string'
                        }];
                        return false;
                      }
                      if (errors === errs_1) {}
                      var valid1 = errors === errs_1;
                    }
                    if (valid1) {
                      var data1 = data.templateData;
                      if (data1 === undefined) {
                        valid1 = true;
                      } else {
                        var errs_1 = errors;
                        if ((!data1 || typeof data1 !== "object" || Array.isArray(data1))) {
                          validate.errors = [{
                            keyword: 'type',
                            dataPath: (dataPath || '') + '.templateData',
                            schemaPath: '#/properties/templateData/type',
                            params: {
                              type: 'object'
                            },
                            message: 'should be object'
                          }];
                          return false;
                        }
                        var valid1 = errors === errs_1;
                      }
                      if (valid1) {
                        var data1 = data.attachments;
                        if (data1 === undefined) {
                          valid1 = true;
                        } else {
                          var errs_1 = errors;
                          if (Array.isArray(data1)) {
                            var errs__1 = errors;
                            var valid1;
                            for (var i1 = 0; i1 < data1.length; i1++) {
                              var data2 = data1[i1];
                              var errs_2 = errors;
                              if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
                                if (true) {
                                  var errs__2 = errors;
                                  var valid3 = true;
                                  var data3 = data2.content;
                                  if (data3 === undefined) {
                                    valid3 = false;
                                    validate.errors = [{
                                      keyword: 'required',
                                      dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                      schemaPath: '#/properties/attachments/items/required',
                                      params: {
                                        missingProperty: 'content'
                                      },
                                      message: 'should have required property \'content\''
                                    }];
                                    return false;
                                  } else {
                                    var errs_3 = errors;
                                    var errs__3 = errors,
                                      prevValid3 = false,
                                      valid3 = false,
                                      passingSchemas3 = null;
                                    var errs_4 = errors;
                                    if (typeof data3 === "string") {
                                      if (ucs2length(data3) < 1) {
                                        var err = {
                                          keyword: 'minLength',
                                          dataPath: (dataPath || '') + '.attachments[' + i1 + '].content',
                                          schemaPath: '#/properties/attachments/items/properties/content/oneOf/0/minLength',
                                          params: {
                                            limit: 1
                                          },
                                          message: 'should NOT be shorter than 1 characters'
                                        };
                                        if (vErrors === null) vErrors = [err];
                                        else vErrors.push(err);
                                        errors++;
                                      } else {}
                                    } else {
                                      var err = {
                                        keyword: 'type',
                                        dataPath: (dataPath || '') + '.attachments[' + i1 + '].content',
                                        schemaPath: '#/properties/attachments/items/properties/content/oneOf/0/type',
                                        params: {
                                          type: 'string'
                                        },
                                        message: 'should be string'
                                      };
                                      if (vErrors === null) vErrors = [err];
                                      else vErrors.push(err);
                                      errors++;
                                    }
                                    if (errors === errs_4) {}
                                    var valid4 = errors === errs_4;
                                    if (valid4) {
                                      valid3 = prevValid3 = true;
                                      passingSchemas3 = 0;
                                    }
                                    var errs_4 = errors;
                                    if (!refVal2(data3, (dataPath || '') + '.attachments[' + i1 + '].content', data2, 'content', rootData)) {
                                      if (vErrors === null) vErrors = refVal2.errors;
                                      else vErrors = vErrors.concat(refVal2.errors);
                                      errors = vErrors.length;
                                    } else {}
                                    if (errors === errs_4) {}
                                    var valid4 = errors === errs_4;
                                    if (valid4 && prevValid3) {
                                      valid3 = false;
                                      passingSchemas3 = [passingSchemas3, 1];
                                    } else {
                                      if (valid4) {
                                        valid3 = prevValid3 = true;
                                        passingSchemas3 = 1;
                                      }
                                    }
                                    if (!valid3) {
                                      var err = {
                                        keyword: 'oneOf',
                                        dataPath: (dataPath || '') + '.attachments[' + i1 + '].content',
                                        schemaPath: '#/properties/attachments/items/properties/content/oneOf',
                                        params: {
                                          passingSchemas: passingSchemas3
                                        },
                                        message: 'should match exactly one schema in oneOf'
                                      };
                                      if (vErrors === null) vErrors = [err];
                                      else vErrors.push(err);
                                      errors++;
                                      validate.errors = vErrors;
                                      return false;
                                    } else {
                                      errors = errs__3;
                                      if (vErrors !== null) {
                                        if (errs__3) vErrors.length = errs__3;
                                        else vErrors = null;
                                      }
                                    }
                                    if (errors === errs_3) {}
                                    var valid3 = errors === errs_3;
                                  }
                                  if (valid3) {
                                    var data3 = data2.filename;
                                    if (data3 === undefined) {
                                      valid3 = false;
                                      validate.errors = [{
                                        keyword: 'required',
                                        dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                        schemaPath: '#/properties/attachments/items/required',
                                        params: {
                                          missingProperty: 'filename'
                                        },
                                        message: 'should have required property \'filename\''
                                      }];
                                      return false;
                                    } else {
                                      var errs_3 = errors;
                                      if (typeof data3 === "string") {
                                        if (ucs2length(data3) < 1) {
                                          validate.errors = [{
                                            keyword: 'minLength',
                                            dataPath: (dataPath || '') + '.attachments[' + i1 + '].filename',
                                            schemaPath: '#/properties/attachments/items/properties/filename/minLength',
                                            params: {
                                              limit: 1
                                            },
                                            message: 'should NOT be shorter than 1 characters'
                                          }];
                                          return false;
                                        } else {}
                                      } else {
                                        validate.errors = [{
                                          keyword: 'type',
                                          dataPath: (dataPath || '') + '.attachments[' + i1 + '].filename',
                                          schemaPath: '#/properties/attachments/items/properties/filename/type',
                                          params: {
                                            type: 'string'
                                          },
                                          message: 'should be string'
                                        }];
                                        return false;
                                      }
                                      if (errors === errs_3) {}
                                      var valid3 = errors === errs_3;
                                    }
                                    if (valid3) {
                                      var data3 = data2.type;
                                      if (data3 === undefined) {
                                        valid3 = true;
                                      } else {
                                        var errs_3 = errors;
                                        if (typeof data3 === "string") {
                                          if (ucs2length(data3) < 1) {
                                            validate.errors = [{
                                              keyword: 'minLength',
                                              dataPath: (dataPath || '') + '.attachments[' + i1 + '].type',
                                              schemaPath: '#/properties/attachments/items/properties/type/minLength',
                                              params: {
                                                limit: 1
                                              },
                                              message: 'should NOT be shorter than 1 characters'
                                            }];
                                            return false;
                                          } else {}
                                        } else {
                                          validate.errors = [{
                                            keyword: 'type',
                                            dataPath: (dataPath || '') + '.attachments[' + i1 + '].type',
                                            schemaPath: '#/properties/attachments/items/properties/type/type',
                                            params: {
                                              type: 'string'
                                            },
                                            message: 'should be string'
                                          }];
                                          return false;
                                        }
                                        if (errors === errs_3) {}
                                        var valid3 = errors === errs_3;
                                      }
                                      if (valid3) {
                                        if (data2.disposition === undefined) {
                                          valid3 = true;
                                        } else {
                                          var errs_3 = errors;
                                          var schema3 = validate.schema.properties.attachments.items.properties.disposition.enum;
                                          var valid3;
                                          valid3 = false;
                                          for (var i3 = 0; i3 < schema3.length; i3++)
                                            if (equal(data2.disposition, schema3[i3])) {
                                              valid3 = true;
                                              break;
                                            } if (!valid3) {
                                            validate.errors = [{
                                              keyword: 'enum',
                                              dataPath: (dataPath || '') + '.attachments[' + i1 + '].disposition',
                                              schemaPath: '#/properties/attachments/items/properties/disposition/enum',
                                              params: {
                                                allowedValues: schema3
                                              },
                                              message: 'should be equal to one of the allowed values'
                                            }];
                                            return false;
                                          } else {}
                                          if (errors === errs_3) {}
                                          var valid3 = errors === errs_3;
                                        }
                                        if (valid3) {
                                          if (data2.content_id === undefined) {
                                            valid3 = true;
                                          } else {
                                            var errs_3 = errors;
                                            if (typeof data2.content_id !== "string") {
                                              validate.errors = [{
                                                keyword: 'type',
                                                dataPath: (dataPath || '') + '.attachments[' + i1 + '].content_id',
                                                schemaPath: '#/properties/attachments/items/properties/content_id/type',
                                                params: {
                                                  type: 'string'
                                                },
                                                message: 'should be string'
                                              }];
                                              return false;
                                            }
                                            var valid3 = errors === errs_3;
                                          }
                                          if (valid3) {}
                                        }
                                      }
                                    }
                                  }
                                  if (errs__2 == errors) {}
                                }
                              } else {
                                validate.errors = [{
                                  keyword: 'type',
                                  dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                  schemaPath: '#/properties/attachments/items/type',
                                  params: {
                                    type: 'object'
                                  },
                                  message: 'should be object'
                                }];
                                return false;
                              }
                              if (errors === errs_2) {
                                var errs__2 = errors;
                                var valid2 = true;
                                var errs_3 = errors;
                                if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
                                  if (true) {
                                    var errs__3 = errors;
                                    var valid4 = true;
                                    if (data2.disposition === undefined) {
                                      valid4 = false;
                                      var err = {};
                                      if (vErrors === null) vErrors = [err];
                                      else vErrors.push(err);
                                      errors++;
                                    } else {
                                      var errs_4 = errors;
                                      var schema4 = validate.schema.properties.attachments.items.if.properties.disposition.const;
                                      var valid4 = equal(data2.disposition, schema4);
                                      if (!valid4) {
                                        var err = {};
                                        if (vErrors === null) vErrors = [err];
                                        else vErrors.push(err);
                                        errors++;
                                      } else {}
                                      if (errors === errs_4) {}
                                      var valid4 = errors === errs_4;
                                    }
                                    if (valid4) {}
                                    if (errs__3 == errors) {}
                                  }
                                } else {
                                  var err = {};
                                  if (vErrors === null) vErrors = [err];
                                  else vErrors.push(err);
                                  errors++;
                                }
                                if (errors === errs_3) {}
                                var valid3 = errors === errs_3;
                                errors = errs__2;
                                if (vErrors !== null) {
                                  if (errs__2) vErrors.length = errs__2;
                                  else vErrors = null;
                                }
                                if (valid3) {
                                  var errs_3 = errors;
                                  if ((data2 && typeof data2 === "object" && !Array.isArray(data2))) {
                                    var missing3;
                                    if (((data2.content_id === undefined) && (missing3 = '.content_id'))) {
                                      validate.errors = [{
                                        keyword: 'required',
                                        dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                        schemaPath: '#/properties/attachments/items/then/required',
                                        params: {
                                          missingProperty: '' + missing3 + ''
                                        },
                                        message: 'should have required property \'' + missing3 + '\''
                                      }];
                                      return false;
                                    } else {}
                                  } else {
                                    validate.errors = [{
                                      keyword: 'type',
                                      dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                      schemaPath: '#/properties/attachments/items/then/type',
                                      params: {
                                        type: 'object'
                                      },
                                      message: 'should be object'
                                    }];
                                    return false;
                                  }
                                  if (errors === errs_3) {}
                                  var valid3 = errors === errs_3;
                                  valid2 = valid3;
                                }
                                if (!valid2) {
                                  var err = {
                                    keyword: 'if',
                                    dataPath: (dataPath || '') + '.attachments[' + i1 + ']',
                                    schemaPath: '#/properties/attachments/items/if',
                                    params: {
                                      failingKeyword: 'then'
                                    },
                                    message: 'should match "' + 'then' + '" schema'
                                  };
                                  if (vErrors === null) vErrors = [err];
                                  else vErrors.push(err);
                                  errors++;
                                  validate.errors = vErrors;
                                  return false;
                                } else {}
                                if (errors === errs_2) {}
                              }
                              var valid2 = errors === errs_2;
                              if (!valid2) break;
                            }
                            if (errs__1 == errors) {}
                          } else {
                            validate.errors = [{
                              keyword: 'type',
                              dataPath: (dataPath || '') + '.attachments',
                              schemaPath: '#/properties/attachments/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/trellis/service/abalonemail/config/email.schema.json",
  "$schema": "http://json-schema.org/draft-07/schema#",
  "description": "Abalonemail email config format for @oada/job job",
  "type": "object",
  "definitions": {
    "email": {
      "$comment": "TODO: Allow emails like: 'John Doe <john@example.org>'",
      "description": "Object for email and associated person's name",
      "oneOf": [{
        "type": "string",
        "format": "email"
      }, {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          }
        },
        "required": ["email"]
      }]
    }
  },
  "properties": {
    "multiple": {
      "description": "If separate emails to each `to` (true) or if one email to all of `to` (false)",
      "type": "boolean"
    },
    "from": {
      "$ref": "#/definitions/email"
    },
    "to": {
      "oneOf": [{
        "$ref": "#/definitions/email"
      }, {
        "type": "array",
        "items": {
          "$ref": "#/definitions/email"
        }
      }]
    },
    "replyTo": {
      "$ref": "#/definitions/email"
    },
    "subject": {
      "type": "string",
      "minLength": 1
    },
    "text": {
      "type": "string",
      "minLength": 1
    },
    "html": {
      "type": "string",
      "minLength": 1
    },
    "templateData": {
      "type": "object",
      "description": "Data to use when filling out email template"
    },
    "attachments": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "content": {
            "oneOf": [{
              "description": "Base 64 encoded attachment content",
              "type": "string",
              "minLength": 1
            }, {
              "description": "Link to OADA resource to use as content",
              "$ref": "../../../../oada.schema.json#/definitions/link"
            }]
          },
          "filename": {
            "type": "string",
            "minLength": 1
          },
          "type": {
            "type": "string",
            "minLength": 1
          },
          "disposition": {
            "enum": ["inline", "attachment"],
            "default": "attachment"
          },
          "content_id": {
            "type": "string"
          }
        },
        "required": ["content", "filename"],
        "if": {
          "type": "object",
          "properties": {
            "disposition": {
              "const": "inline"
            }
          },
          "required": ["disposition"]
        },
        "then": {
          "type": "object",
          "required": ["content_id"]
        }
      }
    }
  },
  "required": ["from", "to"],
  "examples": [{
    "multiple": false,
    "from": "john@example.com",
    "to": {
      "name": "Mary Lou",
      "email": "donuts@example.org"
    },
    "subject": "Test mail",
    "text": "Test!",
    "html": "<h1>Test!</h1>",
    "attachments": [{
      "content": "RXhhbXBsZSBkYXRh",
      "filename": "test.dat",
      "type": "plain/text"
    }, {
      "content": {
        "_id": "resources/abc123"
      },
      "filename": "file.pdf",
      "type": "application/pdf"
    }]
  }]
};
validate.errors = null;
module.exports = validate;