(value, field, maxLength)
| 169 | } |
| 170 | |
| 171 | function requiredString(value, field, maxLength) { |
| 172 | if (typeof value !== "string") { |
| 173 | throw new LoopValidationError(`${field} is required.`); |
| 174 | } |
| 175 | |
| 176 | const normalized = value.trim(); |
| 177 | |
| 178 | if (!normalized || normalized.length > maxLength) { |
| 179 | throw new LoopValidationError(`${field} must be between 1 and ${maxLength} characters.`); |
| 180 | } |
| 181 | |
| 182 | return normalized; |
| 183 | } |
| 184 | |
| 185 | function optionalString(value, field, maxLength) { |
| 186 | if (value === undefined || value === null || value === "") { |
no outgoing calls
no test coverage detected