(key: string, options: { allowEmpty?: boolean } = {})
| 25 | } |
| 26 | |
| 27 | export function requiredString(key: string, options: { allowEmpty?: boolean } = {}): ParamCheck { |
| 28 | return (record) => { |
| 29 | const value = record[key] |
| 30 | if (typeof value !== "string" || (!options.allowEmpty && value.length < 1)) { |
| 31 | return paramsError(`$.${key}`, `${key} must be ${options.allowEmpty ? "a string" : "a non-empty string"}`) |
| 32 | } |
| 33 | return null |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export function optionalString(key: string): ParamCheck { |
| 38 | return (record) => { |
no test coverage detected