Skip to content

Instantly share code, notes, and snippets.

@theorigin
Created August 19, 2014 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save theorigin/cb59ecd19a4852e3a28f to your computer and use it in GitHub Desktop.
Save theorigin/cb59ecd19a4852e3a28f to your computer and use it in GitHub Desktop.
Validation of date in JSON using JSON schema
{
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"properties": {
"orderDate": {
"type": "string",
"format": "date"
}
}
}
{
"orderDate": "2014-02-31"
}
Results :-
[ {
"level" : "error",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/orderDate"
},
"instance" : {
"pointer" : "/orderDate"
},
"domain" : "validation",
"keyword" : "format",
"attribute" : "date",
"message" : "string \"2014-02-31\" is invalid against requested date format(s) yyyy-MM-dd",
"value" : "2014-02-31",
"expected" : "yyyy-MM-dd"
} ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment