(value, maxLength)
| 584 | } |
| 585 | |
| 586 | function 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 | |
| 604 | async function verifyTurnstile( |
| 605 | env, |
no outgoing calls
no test coverage detected