| 537 | |
| 538 | // Baseline query document validation |
| 539 | function invalidDoc(doc) { |
| 540 | if (doc.query) { |
| 541 | if (typeof doc.query.type != "string") return ".query.type must be a string"; |
| 542 | if (doc.query.start && !isPosition(doc.query.start)) return ".query.start must be a position"; |
| 543 | if (doc.query.end && !isPosition(doc.query.end)) return ".query.end must be a position"; |
| 544 | } |
| 545 | if (doc.files) { |
| 546 | if (!Array.isArray(doc.files)) return "Files property must be an array"; |
| 547 | for (var i = 0; i < doc.files.length; ++i) { |
| 548 | var file = doc.files[i]; |
| 549 | if (typeof file != "object") return ".files[n] must be objects"; |
| 550 | else if (typeof file.name != "string") return ".files[n].name must be a string"; |
| 551 | else if (file.type == "delete") continue; |
| 552 | else if (typeof file.text != "string") return ".files[n].text must be a string"; |
| 553 | else if (file.type == "part") { |
| 554 | if (!isPosition(file.offset) && typeof file.offsetLines != "number") |
| 555 | return ".files[n].offset must be a position"; |
| 556 | } else if (file.type != "full") return ".files[n].type must be \"full\" or \"part\""; |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | var offsetSkipLines = 25; |
| 562 | |