Skip to content

Commit

Permalink
fix(all): a single allowed value causes failure
Browse files Browse the repository at this point in the history
We are checking for the second value of allowed values first when checking for booleans. This causes a failure when only one allowed value
is provided for a parameter.
  • Loading branch information
TheRealAmazonKendra committed Apr 29, 2024
1 parent 30b6068 commit 97c6ead
Show file tree
Hide file tree
Showing 2 changed files with 886 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ir/constructor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ impl Constructor {
crate::parser::parameters::ParameterType::String => {
if param.allowed_values.is_some() {
let values = param.allowed_values.clone().unwrap();
if (values[0].to_lowercase() == "true"
&& values[1].to_lowercase() == "false")
|| (values[1].to_lowercase() == "true"
&& values[0].to_lowercase() == "false")
{
crate::parser::parameters::ParameterType::Bool.to_string()
if values.len() == 2 {
if (values[0].to_lowercase() == "true"
&& values[1].to_lowercase() == "false")
|| (values[0].to_lowercase() == "false"
&& values[1].to_lowercase() == "true")
{
crate::parser::parameters::ParameterType::Bool.to_string()
} else {
param.parameter_type.to_string()
}
} else {
param.parameter_type.to_string()
}
Expand Down
Loading

0 comments on commit 97c6ead

Please sign in to comment.