{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "Secure Sail Solutions RFQ",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "organisation",
    "contact_email",
    "interest"
  ],
  "properties": {
    "organisation": {
      "type": "string",
      "minLength": 2,
      "maxLength": 200
    },
    "contact_email": {
      "type": "string",
      "minLength": 5,
      "maxLength": 200
    },
    "fleet_size_band": {
      "type": "string",
      "enum": [
        "1-5",
        "6-20",
        "21-50",
        "51+"
      ]
    },
    "interest": {
      "type": "array",
      "minItems": 1,
      "items": {
        "type": "string",
        "enum": [
          "assessment",
          "systems",
          "deployment",
          "training",
          "officers-training",
          "platform",
          "basic",
          "standard",
          "premium"
        ]
      }
    },
    "voyage_scope": {
      "type": "object",
      "additionalProperties": false,
      "description": "Required when interest includes assessment. IMO number of every vessel in the assessment, corridor names, and cargo class. No waypoints, manifests, crew lists or security plans.",
      "required": [
        "scope",
        "imo_numbers",
        "route_corridors",
        "cargo_class"
      ],
      "properties": {
        "scope": {
          "type": "string",
          "enum": [
            "single-vessel",
            "fleet"
          ]
        },
        "imo_numbers": {
          "type": "array",
          "minItems": 1,
          "maxItems": 200,
          "uniqueItems": true,
          "description": "IMO ship identification number for every vessel to assess. Unique seven-digit hull identity, used to establish characteristics. Example: 9624550 (general cargo ship Oceanic). Prefix IMO is optional.",
          "items": {
            "type": "string",
            "pattern": "^([Ii][Mm][Oo][ -]?)?[0-9]{7}$"
          }
        },
        "route_corridors": {
          "type": "array",
          "minItems": 1,
          "maxItems": 20,
          "items": {
            "type": "string",
            "minLength": 2,
            "maxLength": 200
          }
        },
        "cargo_class": {
          "type": "string",
          "enum": [
            "container",
            "dry-bulk",
            "tanker",
            "roro",
            "general",
            "other"
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "scope": {
                "const": "single-vessel"
              }
            },
            "required": [
              "scope"
            ]
          },
          "then": {
            "properties": {
              "imo_numbers": {
                "maxItems": 1
              }
            }
          }
        }
      ]
    },
    "notes": {
      "type": "string",
      "maxLength": 2000
    },
    "agent_name": {
      "type": "string",
      "maxLength": 200
    }
  },
  "if": {
    "properties": {
      "interest": {
        "contains": {
          "const": "assessment"
        }
      }
    },
    "required": [
      "interest"
    ]
  },
  "then": {
    "required": [
      "voyage_scope"
    ]
  }
}
