diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py index 45a9927..b62457b 100644 --- a/module_utils/network_lsr/argument_validator.py +++ b/module_utils/network_lsr/argument_validator.py @@ -271,7 +271,11 @@ class ArgValidatorNum(ArgValidator): def _validate_impl(self, value, name): v = None try: - if isinstance(value, self.numeric_type): + if isinstance(value, bool): + # bool can (probably) be converted to self.numeric_type, + # but here we don't want to accept a boolean value. + pass + elif isinstance(value, self.numeric_type): # ArgValidatorNum should normalize the input values to be of type # self.numeric_type, except the default_value v = self.numeric_type(value) diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index f7ec527..0d8bd5d 100644 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -384,6 +384,8 @@ class TestValidator(unittest.TestCase): v = network_lsr.argument_validator.ArgValidatorNum("state", required=True) self.assertValidationError(v, None) + self.assertValidationError(v, False) + self.assertValidationError(v, True) def test_validate_bool(self):