Values API default values
See original GitHub issueWe know that you’re working hard on getting v2 ready for release, so it seems like a good time to formally propose an enhancement to the specification proposed in #202 to support providing default values.
The best syntax I’ve seen so far was proposed by @dancallaghan in his comment on the PR:
static values = {
url: String,
refreshInterval: [Number, 300],
loadOnConnect: [Boolean, true]
}
I love this because it’s non-intrusive and falls back to the current syntax.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:43
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Web API model validation and default values - Stack Overflow
If I specify a blank value for something (i.e. GET test/123?something= ), then the default value comes into play, and the model is...
Read more >Default values | Contentful Help Center
Default values are predefined values that are set for specific fields in a content type. They help you bring more consistency into your...
Read more >Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >Values API default values · Issue #335 · hotwired/stimulus
The value API is perfect to create those options. Default values would make it simpler rather than having new getters as @olimart pointed....
Read more >Get Default Values to Create a Record - Salesforce Developers
To get default values with a more lightweight response, use the /ui-api/record-defaults/template/create/{objectApiName} resource.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I dig this default values design where types are inferred from the values. So 👍 from here.
In that example,
[Number, 300]
feels redundant because300
is already aNumber
. So Stimulus would also need to deal with inconsistency between declared type and default type (or decide not to, and error).Couldn’t it be instead either the type or the value?
The type could always be inferred from the value. (Even if
typeof
Array being Object is a little annoying, the Object case would always be further checked for the Array type.)