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

Optional config item without default value #54

Closed
raharrison opened this issue Apr 7, 2020 · 1 comment
Closed

Optional config item without default value #54

raharrison opened this issue Apr 7, 2020 · 1 comment

Comments

@raharrison
Copy link

Is it possible to create a config property which is optional without having to provide a default value? Thinking something like the below which can be retrieved from the Config object as a Kotlin nullable variable. Have the case where a config value is either defined or not, there would be no default value.

object AppSpec : ConfigSpec() {
    val host by required("0.0.0.0")
    val resourcePath by optional<String>() // no default value
}

Then when retrieved something like

// as nullable var
val resourcePath : String? = config[AppSpec.resourcePath]

(Great library by the way)

@raharrison
Copy link
Author

Nearly had it can be achieved with

val resourcePath by optional<String>(null)

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