-
Notifications
You must be signed in to change notification settings - Fork 150
Warn if given default value doesn't exist in values list #314
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
Warn if given default value doesn't exist in values list #314
Conversation
8ed1d02 to
9c6df30
Compare
|
Hi @yusufyildirim! Thanks for the PR. Before moving on with this change, we need to decide how strict the
Any other alternative we should consider? BTW, this differentiation is even more important if we want to start validating properties passed as literals in the markup. Normally, you'd define a default value that is already on the list of values, however, non-default values passed by the user may not be predictable. |
|
I always assumed I like option 1, the naming is clear enough to me. I'm surprised option 2 is even possible and I believe it would cause confusion, as it's not very standard Elixir. Another option I can think of is to have a boolean |
@miguel-s that notation is valid Elixir code. That syntax is mostly used to define type specs. For example, the following type is valid: Where However, I agree it might be confusing, although it's very handy :) |
|
I didn't think that way 😄 I assumed |
|
Another option would be to keep |
|
Alright. Time to vote!
/cc @surface-ui/core |
|
I'd say 2. is the most obvious and least verbose 😄 |
3 |
2, but only a slight preference over 3 |
|
Although I slightly prefer @yusufyildirim feel free to move on and let's know if you need any assistance. Thanks for working on this! |
9c6df30 to
0c088f8
Compare
|
Hi @yusufyildirim! Just to make it clear, we're only checking if the default value is in the list if the user sets We'll also need to find a way to indicate this difference The first thing that comes to my mind is to add Any other idea? Another 2 things we could validate in a separate PR:
|
|
Hi @msaraiva Yes, everything is clear. I didn't have time to work on this for now BTW.
Totally makes sense. I'm a bit worried about series of numbers though. Adding I don't know if I explained it well but this might worth thinking a bit. Except that, it's ok. |
Yeah. It could give that impression. Another option could be:
or maybe add a prefix "Suggestions": Suggestions: But that's quite verbose. Not sure. |
|
I don't know, maybe we should just add a sentence or a paragraph that explains what |
|
Hello @yusufyildirim, do you need help with this PR? I've similarly become interested in this problem, as well as adding some possibilities with ranges in values so you can do things like prop age, :integer, values!: 1..100 |
|
Regardless of my suggestion, which probably is a separate topic, I'm happy to take over this PR to push it over the line. |
|
Hello @davydog187, I'm pretty busy these days -even weekends- and this is why I couldn't find time to implement this. If you want to continue, please feel free to take over |
|
Great, and I'll add support for my current PR #355 Thank you @yusufyildirim |
|
Started work on this :) |
|
I just opened #374 |
|
Closing this one, thank you @davydog187! |

Hi,
This PR's scope discussed a bit in #312. I've found a couple of cases:
We should be checking if the given default value exists in the values list (for data and prop and if not accumulated)
Example (should give warning):
prop type, :string, values: ["small", "medium", "large"], default: "x-large"We should be checking if the given default value(s) exist in the value list (only for prop and if accumulated)
Example(should give warning):
prop count, :integer, default: [3], values: [0, 1, 2], accumulate: trueShould be valid
prop count, :integer, default: [], values: [0, 1, 2], accumulate: trueThere are some more cases but that is the core idea.
I'm an Elixir newbie and this is why I struggled to bring idiomatic Elixir code to the table 🙈I definitely need your feedback and this code definitely needs splitting. Please, guide me through if you have time.
Thank you in advance!