【发布时间】:2020-07-11 22:11:00
【问题描述】:
我的请求正文:
[
{
"postId": 1,
"id": 1,
"name": "name abc",
"email": "Eliseo@gardner.biz",
"body": "something"
},
...
]
我正在尝试如下验证:
var schema = {
"type": "array",
"properties": {
"postId": {
"type": "integer"
},
"id": {
"type": "integer"
},
"name": {
"type": "string"
},
"email": {
"type": "string",
"pattern": "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$"
},
"body": {
"type": "string"
}
},
"required": [
"postId",
"id",
"name",
"email",
"body"
]
};
pm.test('Schemat jest poprawny', function() {
pm.expect(tv4.validate(jsonData, schema)).to.be.true;
});
即使我更改了字符串的 id 类型或无效的电子邮件模式,测试也可以。
那段代码有什么问题?
【问题讨论】:
标签: validation postman schema