Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typepanion Literal Number and Option.String do not play nice together #125

Open
xenoterracide opened this issue Jul 28, 2022 · 0 comments
Open

Comments

@xenoterracide
Copy link

xenoterracide commented Jul 28, 2022

// don't use well known ports
const isPort = isOneOf(
  [isLiteral(0), cascade(isNumber(), isInteger(), isPositive(), isInInclusiveRange(1024, 65535))],
  { exclusive: true },
)

export class App extends Command {
  readonly port = Option.String('--port', '0', { validator: isPort })

  static readonly paths = [Command.Default]
 }

unfortunately OptionString cannot take a number, and so literal 0 will fail

❯ yarn workspace @cof/e1-fake-chamber-of-secrets serve
Usage Error: Invalid value for port:

- .#1: Expected 0 (got "0")
- .#2: Expected to be in the [1024; 65535] range (got 0)

I guess my suggestion for a fix would be to allow a subset of primitives to Option.String fortunately express seems ok with the string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant