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

InputParameters' "default" value used when an invalid "options" value is provided #1531

Closed
jnapprogs opened this issue Feb 4, 2022 · 5 comments · Fixed by #1579
Closed

Comments

@jnapprogs
Copy link

jnapprogs commented Feb 4, 2022

Hi all! I was wondering if I can get some insight for the behavior of the default property for the InputParameters type. I have an input parameter initialized as follows:

const inputParams = {
  item: {
    aliases: ['item'],
    required: false,
    type: 'string',
    default: 'first',
    options: ['first', 'second', 'third']
  }
}

If I do not provide a value for the item parameter, then it defaults to first. If I specify any of the values in the options property, then that value is used instead; however, if I was to provide a value that isn't part of the options property, say this should break, it defaults to first. Even though a default value has been specified, I assumed that the adapter would throw an error as a value has been provided that isn't part of the options property. As an external user, if I wanted a fourth item, I would keep receiving back the first item.

With that, is the default value intended to be used in the event a user does not provide a value, or does it also play a dual role in being the default value if a wrong options value is provided?

@austinborn
Copy link
Contributor

Hi @jnapprogs, thank you for pointing this out. I don't have an immediate answer for you since this does not appear to be due to the Validator class itself, but I would expect proper behavior to be to throw an error as well. We have added it to the bug queue and will prioritize accordingly. Happy to give further assistance if you would like to debug as well.

@jnapprogs
Copy link
Author

@austinborn , thanks for the response! I should be fine on the debugging front, but will definitely reach out in the event I have to 🚀

@austinborn
Copy link
Contributor

austinborn commented Feb 17, 2022

@jnapprogs I believe this should resolve the issues you were seeing. With this change, an input that's not a part of the options array will return an error instead of silently defaulting to the default value.

@jnapprogs
Copy link
Author

Awesome! Thanks for the info!

@austinborn
Copy link
Contributor

Awesome! Thanks for the info!

Of course! Happy to get a quick turnaround on this one.

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

Successfully merging a pull request may close this issue.

2 participants