(key: string)
| 86 | } |
| 87 | |
| 88 | export function optionalStringArray(key: string): ParamCheck { |
| 89 | return (record) => { |
| 90 | const value = record[key] |
| 91 | if (value === undefined) return null |
| 92 | if (!Array.isArray(value)) return paramsError(`$.${key}`, `${key} must be an array`) |
| 93 | for (let i = 0; i < value.length; i++) { |
| 94 | if (typeof value[i] !== "string") return paramsError(`$.${key}[${i}]`, `${key} entries must be strings`) |
| 95 | } |
| 96 | return null |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | export function optionalStringRecord(key: string): ParamCheck { |
| 101 | return (record) => { |
no test coverage detected