Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format "date-time" requiring #19

Open
j94305 opened this issue Jul 6, 2023 · 0 comments
Open

Format "date-time" requiring #19

j94305 opened this issue Jul 6, 2023 · 0 comments

Comments

@j94305
Copy link

j94305 commented Jul 6, 2023

Create a schema:

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "title": "Timestamp Test",
    "type": "object",
    
    "properties": {
	"@timestamp": {
	    "description": "The UTC date and time the event was created",
	    "type": "string",
	    "format": "date-time"
	}
    }
}

Create three test JSON files:

{
    "@timestamp": "2023-07-06T20:20:10.388-02:00"
}
{
    "@timestamp": "2023-07-06T20:20:10.388Z"
}
{
    "@timestamp": "2023-07-06T20:20:10.388"
}

The first two will validate against the schema, the third one does not.

The standard ISO 8601 date/time specification makes the timezone specification optional. Other JSON Schema libraries handle this correctly (e.g., "check-jsonschema").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant