question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to make switch required?

See original GitHub issue

option().switch(...).required() does not compile, neither does option().required().switch(...).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ajaltcommented, Sep 24, 2020

There isn’t a required() extension for flag/switch options. You can write your own like this:

fun <T : Any> FlagOption<T?>.required(): FlagOption<T> {
    return copy(
            transformEnvvar = { transformEnvvar(it) ?: throw MissingOption(option) },
            transformAll = { transformAll(it) ?: throw MissingOption(option) },
            validator = validator,
    )
}

Since we already have a default() extension, I think it would make sense to add this as a built in extension.

0reactions
ajaltcommented, Sep 25, 2020

That’s the plan.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To FIX Nintendo Switch “ Registration is required to use ...
How To FIX Nintendo Switch “ Registration is required to use this network “ | Full Tutorial.
Read more >
Java switch statement: Constant expression required, but it IS ...
The fix is simple; change the Foo.BA* variable declarations to have initializers that are compile-time constant expressions. In other examples (where the ...
Read more >
Got Yourself A New Nintendo Switch? Do These Things First
You'll receive a registration code, which you now have to fill in on your Switch. Repeat steps one to three above and fill...
Read more >
switch - JavaScript - MDN Web Docs - Mozilla
The switch statement evaluates an expression, matching the expression's value against a series of case clauses, and executes statements ...
Read more >
Minimum Network Switch Requirements - Avigilon
Two switches are required for redundancy. · Each switch must support at least 10 GbE networking speeds. · Each switch must have 4...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found