Skip to content

Site Payload Validation

This document describes the validation rules applied to the Site GeoJSON payloads in the system. The validation is performed in two layers:

  1. JSON Schema Validation: Structural and field-level constraints.
  2. Runtime Validation: Business rules and contextual consistency enforced by application logic.
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://geojson.org/schema/Site.json",
  "title": "GeoJSON Site",
  "type": "object",
  "required": [
    "type",
    "features"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "FeatureCollection"
      ]
    },
    "features": {
      "type": "array",
      "items": {
        "title": "GeoJSON Site",
        "type": "object",
        "required": [
          "type",
          "properties",
          "geometry"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "Feature"
            ]
          },
          "id": {
            "type": "number"
          },
          "properties": {
            "type": "object",
            "required": [
              "fid",
              "name",
              "typeCode"
            ],
            "properties": {
              "fid": {
                "type": "string",
                "maxLength": 36,
                "minLength": 1
              },
              "name": {
                "type": "string",
                "maxLength": 50,
                "minLength": 0
              },
              "typeCode": {
                "type": "string",
                "enum": [
                    "site-outline"
                ]
              }
            }
          },
          "geometry": {
            "oneOf": [
              {
                "title": "GeoJSON Polygon",
                "type": "object",
                "required": ["type", "coordinates"],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": ["Polygon"]
                  },
                  "coordinates": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "array",
                      "minItems": 4,
                      "items": {
                        "type": "array",
                        "minItems": 2,
                        "items": [
                          {
                            "type": "number",
                            "multipleOf": 0.00000001,
                            "exclusiveMinimum": -180,
                            "exclusiveMaximum": 180
                          },
                          {
                            "type": "number",
                            "multipleOf": 0.00000001,
                            "exclusiveMinimum": -90,
                            "exclusiveMaximum": 90
                          }
                        ]
                      }
                    }
                  },
                  "bbox": {
                    "type": "array",
                    "minItems": 4,
                    "items": {
                      "type": "number"
                    }
                  }
                }
              },
              {
                "title": "GeoJSON MultiPolygon",
                "type": "object",
                "required": ["type", "coordinates"],
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": ["MultiPolygon"]
                  },
                  "coordinates": {
                    "type": "array",
                    "minItems": 1,
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "array",
                        "minItems": 4,
                        "items": {
                          "type": "array",
                          "minItems": 2,
                          "items": [
                            {
                              "type": "number",
                              "multipleOf": 0.00000001,
                              "exclusiveMinimum": -180,
                              "exclusiveMaximum": 180
                            },
                            {
                              "type": "number",
                              "multipleOf": 0.00000001,
                              "exclusiveMinimum": -90,
                              "exclusiveMaximum": 90
                            }
                          ]
                        }
                      }
                    }
                  },
                  "bbox": {
                    "type": "array",
                    "minItems": 4,
                    "items": {
                      "type": "number"
                    }
                  }
                }
              }
            ]
          },
          "bbox": {
            "type": "array",
            "minItems": 4,
            "items": {
              "type": "number"
            }
          }
        }
      }
    },
    "bbox": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "number"
      }
    }
  }
}

1. JSON Schema Validation

The JSON payload must follow the FeatureCollection pattern and contain an array of Feature items, each representing a site.

🔸 Root Object

  • type: "FeatureCollection" (required)
  • features: array of GeoJSON Feature objects (required)
  • bbox: optional array with at least 4 numbers

🔸 features[].type

  • Must be "Feature" (required)

🔸 features[].id

  • Optional numeric identifier

🔸 features[].properties

  • Must include the following fields (required):
    • fid: string (length: 1–36)
    • name: string (max length: 50)
    • typeCode: must be "site-outline"

🔸 features[].geometry

  • Must be either a GeoJSON Polygon or MultiPolygon
  • Coordinates must:

    • Conform to valid GeoJSON structure
    • Include at least 4 coordinate points for each ring
    • Have latitude (lat) in range (-90, 90) and longitude (lon) in range (-180, 180), with high precision.
  • Optional bbox array with at least 4 numbers

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://geojson.org/schema/Site.json",
  "title": "GeoJSON Site",
  "type": "object",
  "required": [
    "type",
    "properties",
    "geometry"
  ],
  "properties": {
    "type": {
      "type": "string",
      "enum": [
        "Feature"
      ]
    },
    "id": {
      "type": "number"
    },
    "properties": {
      "type": "object",
      "required": [
        "fid",
        "name",
        "typeCode"
      ],
      "properties": {
        "fid": {
          "type": "string",
          "maxLength": 36,
          "minLength": 1
        },
        "name": {
          "type": "string",
          "maxLength": 50,
          "minLength": 0
        },
        "typeCode": {
          "type": "string",
          "enum": [
              "site-outline"
          ]
        }
      }
    },
    "geometry": {
      "oneOf": [
        {
          "title": "GeoJSON Polygon",
          "type": "object",
          "required": ["type", "coordinates"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["Polygon"]
            },
            "coordinates": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "array",
                "minItems": 4,
                "items": {
                  "type": "array",
                  "minItems": 2,
                  "items": [
                    {
                      "type": "number",
                      "multipleOf": 0.00000001,
                      "exclusiveMinimum": -180,
                      "exclusiveMaximum": 180
                    },
                    {
                      "type": "number",
                      "multipleOf": 0.00000001,
                      "exclusiveMinimum": -90,
                      "exclusiveMaximum": 90
                    }
                  ]
                }
              }
            },
            "bbox": {
              "type": "array",
              "minItems": 4,
              "items": {
                "type": "number"
              }
            }
          }
        },
        {
          "title": "GeoJSON MultiPolygon",
          "type": "object",
          "required": ["type", "coordinates"],
          "properties": {
            "type": {
              "type": "string",
              "enum": ["MultiPolygon"]
            },
            "coordinates": {
              "type": "array",
              "minItems": 1,
              "items": {
                "type": "array",
                "items": {
                  "type": "array",
                  "minItems": 4,
                  "items": {
                    "type": "array",
                    "minItems": 2,
                    "items": [
                      {
                        "type": "number",
                        "multipleOf": 0.00000001,
                        "exclusiveMinimum": -180,
                        "exclusiveMaximum": 180
                      },
                      {
                        "type": "number",
                        "multipleOf": 0.00000001,
                        "exclusiveMinimum": -90,
                        "exclusiveMaximum": 90
                      }
                    ]
                  }
                }
              }
            },
            "bbox": {
              "type": "array",
              "minItems": 4,
              "items": {
                "type": "number"
              }
            }
          }
        }
      ]
    },
    "bbox": {
      "type": "array",
      "minItems": 4,
      "items": {
        "type": "number"
      }
    }
  }
}

1. JSON Schema Validation

The incoming payload must conform to the following rules defined in the JSON Schema:

🔸 Root Object

  • type: must be "Feature" (required).
  • id: optional numeric identifier.
  • bbox: optional array with at least 4 numerical values.

🔸 properties Object

  • fid (Feature Identifier):

    • Required
    • String
    • Minimum length: 1
    • Maximum length: 36
  • name:

    • Required
    • String
    • Maximum length: 255
  • typeCode:

    • Required
    • Must be "site-outline"
  • Other fields are allowed unless explicitly forbidden (see Runtime Validation section).

🔸 geometry Object

  • Must be a valid GeoJSON Polygon or MultiPolygon object.
    • Conform to valid GeoJSON structure.
    • Include at least 4 coordinate points for each ring.
    • Have latitude (lat) in range (-90, 90) and longitude (lon) in range (-180, 180), with high precision.

    Coordinates must:

    • Optional bbox field must be an array of at least 4 numbers.

2. Runtime Validations (Application Logic)

These rules are enforced at runtime and cannot be expressed via JSON Schema alone:

🔹 1. fid (Feature Identifier)

  • If fid is missing or null:
    → Returns "fid is required."

  • If fid is provided but invalid:
    → Returns "The fid field contains an invalid value."

  • If a siteIdentifier is provided but does not match the payload's fid:
    → Returns "The requested siteIdentifier and payload fid do not match."

  • If no siteIdentifier is provided and a site with the same fid already exists:
    → Returns "The site with given fid is already exist."

🔹 2. name

  • If missing or empty:
    → Returns "The name field cannot be empty."

  • If longer than allowed maximum (e.g., 255):
    → Returns "Site name cannot exceed '255' characters."

🔹 3. eid (External Identifier)

  • If present and empty:
    → Returns "The eid field cannot be empty."

  • If present and already used by another site (different fid):
    → Returns "Another site exists with the same siteExternalIdentifier for this client."

🔹 4. Forbidden Properties

The following fields are not allowed in the properties object. Their presence will cause validation to fail:

  • "sid" (site identifier reference)
  • "bid" (building identifier reference)
  • "lvl" (level/floor reference)

If any of these fields are found in the payload:
→ Returns "The properties 'sid, bid, lvl' are forbidden."

🔹 5. Geometry Size Constraints

  • The geometry must represent an area smaller than or equal to 10km x 10km.
  • If the geometry exceeds this spatial boundary:
    → Returns "Site size should be maximum 10km x 10km."

By combining schema-level validation with runtime logic, the system ensures robust, reliable, and secure payload processing.