(value, maxLength, label)
| 562 | } |
| 563 | |
| 564 | function 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 | |
| 586 | function readOptionalString(value, maxLength) { |
| 587 | if (value === undefined || value === null || value === "") { |
no outgoing calls
no test coverage detected