Skip to content

Warning issued when an optional field does not allow nulls #535

Open
@edmundadjei

Description

@edmundadjei

There appears to be no way of defining a non-null optional field, you get a validation/linting warning when you publish such a schema, but I feel this is perfectly valid.

I had to make lat/lon type ["number", "null"], but this is not valid, I do not want a null value to be passed in at all, in fact I want to a null value to fail validation for this location schema

        "location": {
          "description": "Place name and lat/Lon coordinates",
          "type": ["object", "null"],
          "properties": {
            "name": {
              "description": "The name of this location, city/town etc",
              "type": "string",
              "maxLength": 2048
            },
            "lat": {
              "description": "Latitude for the location",
              "type": ["number", "null"],
              "minimum": -90,
              "maximum": 90
            },
            "lon": {
              "description": "Longitude for the location",
              "type": ["number", "null"],
              "minimum": -180,
              "maximum": 180
            }
          },
          "required": [
            "name"
          ],
          "dependencies": {
            "lat": ["lon"],
            "lon": ["lat"]
          },
          "additionalProperties" : false
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions