MCPcopy Create free account
hub / github.com/deepnote/deepnote / stringPortValidate

Function stringPortValidate

packages/cli/src/utils/inquirer.ts:6–19  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

4export type StringFieldCustomValidateFn = (value: string) => string | true
5
6export function stringPortValidate(value: string): string | true {
7 // Allow empty string — optional port fields skip validation when left blank
8 if (!value.trim()) {
9 return true
10 }
11 const port = z.coerce.number().safeParse(value)
12 if (!port.success) {
13 return 'Invalid value, expected a number'
14 }
15 if (port.data < 1 || port.data > 65535) {
16 return 'Port must be between 1 and 65535'
17 }
18 return true
19}
20
21export async function promptForStringField({
22 label,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected