summaryrefslogtreecommitdiff
path: root/lib/slop/types.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/slop/types.rb')
-rw-r--r--lib/slop/types.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/slop/types.rb b/lib/slop/types.rb
index a08537d..d68fe76 100644
--- a/lib/slop/types.rb
+++ b/lib/slop/types.rb
@@ -26,6 +26,11 @@ module Slop
VALID_VALUES = (FALSE_VALUES + TRUE_VALUES).freeze
def valid?(value)
+ # If we don't want to validate the type, then we don't care if the value
+ # is valid or not. Otherwise we would prevent boolean flags followed by
+ # arguments from being parsed correctly.
+ return true unless config[:validate_type]
+
return true if value.is_a?(String) && value.start_with?("--")
value.nil? || VALID_VALUES.include?(value)
end