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

Function readRequiredString

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

Source from the content-addressed store, hash-verified

562}
563
564function readRequiredString(value, maxLength, label) {
565 if (typeof value !== "string") {
566 throw new RequestError(
567 400,
568 "invalid_field",
569 `${label} is required.`,
570 );
571 }
572
573 const normalized = value.trim();
574
575 if (!normalized || normalized.length > maxLength) {
576 throw new RequestError(
577 400,
578 "invalid_field",
579 `${label} is invalid.`,
580 );
581 }
582
583 return normalized;
584}
585
586function readOptionalString(value, maxLength) {
587 if (value === undefined || value === null || value === "") {

Callers 2

validateSuggestionFunction · 0.85
validateWeeklySignupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected