MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / invalidDoc

Function invalidDoc

lib/web/tern/tern.js:539–559  ·  view source on GitHub ↗
(doc)

Source from the content-addressed store, hash-verified

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

Callers 1

tern.jsFile · 0.85

Calls 1

isPositionFunction · 0.85

Tested by

no test coverage detected