Skip to content

iso8601 duration validates any type of string #272

Description

@costero-e

The iso8601duration property is defined throughout the spec as a string, e.g. Age where iso8601 is defined as:

    "properties": {
        "iso8601duration": {
            "description": "Represents age as a ISO8601 duration (e.g., P40Y10M05D).",
            "example": "P32Y6M1D",
            "type": "string"
        }
    }

Although in the description it is mentioned that the string must match a ISO8601 duration, in practice this is not enforced to have for any beacon as the json schema validator accepts any type of string. A possible solution would be to reformulate the definition to something like:

    "properties": {
        "iso8601duration": {
            "description": "Represents age as a ISO8601 duration (e.g., P40Y10M05D).",
            "example": "P32Y6M1D",
            "format": "duration"
            "type": "string"
        }
    }

As per the JSON schema spec, which defines duration as an iso8601 duration:

    "duration": {
        "description": "Duration as defined by duration - RFC3339",
        "definingBody": "JSON Schema",
        "definition": "https://json-schema.org/draft/2020-12/json-schema-validation.html#name-dates-times-and-duration",
        "types": ["string"],
        "examples": ["P3Y6M4DT12H30M5S"],
        "deprecated": false,
        "supportedBy": []
    }

But this would (probably, not sure, as the description is clear) break the spec and would need to be added in a future Beacon v3. Let me know what you think, thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions