2
我正在使用JSON.Schema驗證我的有效內容。日期之一的字段具有以下json模式。Json Schema日期驗證
"Date": {
"type": "object",
"properties": {
"Value": {
"type": "string",
"format": "date"
}
},
"required": [ "Value" ],
"additionalProperties": false
}
在我的服務器端(WEB API C#)我驗證JSON如下。
var schema = JSchema.Parse(jsonSchema);
var livestockRow = JObject.Parse(jsonData);
IList<ValidationError> errorMessages;
livestockRow.IsValid(schema, out errorMessages);
我通過我的日期爲「24/09/2012」,它回來爲下面的錯誤:
String '24/09/2012' does not validate against format 'date'.
我失去了什麼?
我不能感謝你纔好爲這一個。 – Immortal