Cố gắng viết lược đồ JSON sử dụng RegEx để xác thực giá trị của một mục.Sử dụng RegEx trong Lược đồ JSON
Có một mục có tên là progBinaryName có giá trị nên phù hợp với chuỗi RegEx này "^[A-Za-z0-9 -_]+_Prog\\.(exe|EXE)$"
.
Không thể tìm thấy bất kỳ hướng dẫn hoặc ví dụ nào thực sự giải thích việc sử dụng RegEx trong lược đồ JSON.
Mọi trợ giúp/thông tin sẽ được đánh giá cao!
Cảm ơn, D
JSON SCHEMA
{
"name": "string",
"properties": {
"progName": {
"type": "string",
"description": "Program Name",
"required": true
},
"ID": {
"type": "string",
"description": "Identifier",
"required": true
},
"progVer": {
"type": "string",
"description": "Version number",
"required": true
},
"progBinaryName": {
"type": "string",
"description": "Actual name of binary",
"patternProperties": {
"progBinaryName": "^[A-Za-z0-9 -_]+_Prog\\.(exe|EXE)$"
},
"required": true
}
}
}
LỖI:
Cảnh báo! Kiểm tra JSON của bạn tốt hơn.
Instance không phải là một loại yêu cầu - http://json-schema.org/draft-03/hyper-schema#
Schema là hợp lệ JSON, nhưng không phải là một sơ đồ hợp lệ. kết quả
Validation: thất bại
[ {
"level" : "warning",
"schema" : {
"loadingURI" : "#",
"pointer" : ""
},
"domain" : "syntax",
"message" : "unknown keyword(s) found; ignored",
"ignored" : [ "name" ]
}, {
"level" : "error",
"domain" : "syntax",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/ID"
},
"keyword" : "required",
"message" : "value has incorrect type",
"expected" : [ "array" ],
"found" : "boolean"
}, {
"level" : "error",
"domain" : "syntax",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/progBinaryName"
},
"keyword" : "required",
"message" : "value has incorrect type",
"expected" : [ "array" ],
"found" : "boolean"
}, {
"level" : "error",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/progBinaryName/patternProperties/progBinaryName"
},
"domain" : "syntax",
"message" : "JSON value is not a JSON Schema: not an object",
"found" : "string"
}, {
"level" : "error",
"domain" : "syntax",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/progName"
},
"keyword" : "required",
"message" : "value has incorrect type",
"expected" : [ "array" ],
"found" : "boolean"
}, {
"level" : "error",
"domain" : "syntax",
"schema" : {
"loadingURI" : "#",
"pointer" : "/properties/progVer"
},
"keyword" : "required",
"message" : "value has incorrect type",
"expected" : [ "array" ],
"found" : "boolean"
} ]
Problem with schema#/properties/progBinaryName/patternProperties/progBinaryName : Instance is not a required type
Reported by http://json-schema.org/draft-03/hyper-schema#
Attribute "type" (["object"])
Điều gì không hoạt động? (Bạn có thể muốn đặt dấu gạch nối đó ở cuối lớp nhân vật) –
Bất kỳ xác thực trực tuyến nào không hoạt động đúng. – Destroyer
"Không hoạt động đúng" nghĩa là gì? Bạn có được dương tính giả không? Bạn nhận được âm tính giả? Bạn có nhận được một số loại lỗi? –