2016-03-03 55 views
0

我在嘗試驗證時間間隔之間的日期 - 時間值時出現Json Schema問題[2013-11-17T00:00Z,2015-11- 17T00:00Z]我有這樣的JSON模式:Json Schema,日期 - 時間格式的strictProperties最小和格式最大

{ 
    "strictProperties": true , 
    "type": "object", 
    "properties": { 
    "data": { 
     "type": "object", 
     "properties": { 
     "exampleDate": { 
      "format": "date-time", 
      "formatMinimum": "2013-11-17T00:00Z", 
      "formatMaximum": "2015-11-17T00:00Z" 
     } 
     } 
    } 
    }, 
    "required": [ 
    "data" 
    ] 
} 

而與此JSON總是出是有效的JSON:

{ 
    "data": { 
     "exampleDate": "2010-11-17T00:00:00Z" 
    } 
} 

但你可以看到,這JSON是因爲日期無效,它超出了有效範圍。

我已經在線工具http://www.jsonschemavalidator.net/,http://jsonschemalint.com/draft4/#和com.github.fge測試過:json-schema-validator:2.2.6。請有人幫助我嗎?也許我錯過了strictProperties之外的一些配置?一些步驟?在此先感謝=)

回答

1

formatMinimumformatMaximum不在JSON模式v4草案。他們提出的功能爲V5:

https://github.com/json-schema/json-schema/wiki/formatMinimum-(v5-proposal)

然而,這個庫可以使用v5選項驗證formatMinimumformatMaximum

https://github.com/epoberezkin/ajv#features

+0

我看,以爲它的Java,我雖然爲了啓用V5選項,只有我應該添加strictProperties爲真,如在這裏所說的https://github.com/fge/json-schema-validator/wiki/v5:-strictProperties –