Skip to content

Commit

Permalink
Auto merge of #288 - kbknapp:issue-287, r=sru
Browse files Browse the repository at this point in the history
fix(Possible Values): possible value validation is restored

Closes #287
  • Loading branch information
homu committed Sep 30, 2015
2 parents 1c5f4f2 + f121ae7 commit 5d7ce3e
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2370,8 +2370,8 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
// Check the possible values
if let Some(ref p_vals) = opt.possible_vals {
if !p_vals.contains(&arg_slice) {
self.possible_values_error(arg_slice, &opt.to_string(),
p_vals, matches);
return Err(self.possible_values_error(arg_slice, &opt.to_string(),
p_vals, matches));
}
}
// Check the required number of values
Expand Down Expand Up @@ -2588,9 +2588,10 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{


if let Some(ref p_vals) = p.possible_vals {

if !p_vals.contains(&arg_slice) {
self.possible_values_error(arg_slice, &p.to_string(),
p_vals, matches);
return Err(self.possible_values_error(arg_slice, &p.to_string(),
p_vals, matches));
}
}

Expand Down Expand Up @@ -3356,7 +3357,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
-> Result<(), ClapError> {
if let Some(ref p_vals) = v.possible_vals {
if !p_vals.contains(&av) {
self.possible_values_error(av, &v.to_string(), p_vals, matches);
return Err(self.possible_values_error(av, &v.to_string(), p_vals, matches));
}
}
if !v.empty_vals && av.is_empty() && matches.args.contains_key(v.name) {
Expand Down

0 comments on commit 5d7ce3e

Please sign in to comment.