(options?: NumberValidateOptions)
| 60 | } |
| 61 | |
| 62 | export const numberValidateFn = (options?: NumberValidateOptions): ValidateFunction<number | undefined> => { |
| 63 | if (options?.min != null && options.max != null && options.min > options.max) { |
| 64 | throw Error('max must be >= min') |
| 65 | } |
| 66 | |
| 67 | return (input: number | undefined): true | string => { |
| 68 | if (input == null) { |
| 69 | return true |
| 70 | } |
| 71 | if (options?.min != null && input < options.min) { |
| 72 | return `must be no less than ${options.min}` |
| 73 | } |
| 74 | if (options?.max != null && input > options.max) { |
| 75 | return `must be no more than ${options.max}` |
| 76 | } |
| 77 | return true |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | type URLValidateFnOptions = { |
| 82 | httpsRequired?: boolean |
no outgoing calls
no test coverage detected