MCPcopy Create free account
hub / github.com/Forward-Future/loopy / readOptionalString

Function readOptionalString

loop-library/worker/src/index.js:586–602  ·  view source on GitHub ↗
(value, maxLength)

Source from the content-addressed store, hash-verified

584}
585
586function readOptionalString(value, maxLength) {
587 if (value === undefined || value === null || value === "") {
588 return undefined;
589 }
590
591 if (typeof value !== "string") {
592 throw new RequestError(400, "invalid_field", "The form data is invalid.");
593 }
594
595 const normalized = value.trim();
596
597 if (normalized.length > maxLength) {
598 throw new RequestError(400, "invalid_field", "The form data is invalid.");
599 }
600
601 return normalized || undefined;
602}
603
604async function verifyTurnstile(
605 env,

Callers 2

handleRequestFunction · 0.85
validateSuggestionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected