Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runpod/serverless/utils/rp_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _validate_input_against_schema(schema, validated_input, error_list):

# Check for the correct type.
is_instance = isinstance(validated_input[key], rules["type"])
if validated_input[key] is not None and not is_instance:
if not is_instance:
_add_error(
error_list,
f"{key} should be {rules['type']} type, not {type(validated_input[key])}.",
Expand Down
18 changes: 18 additions & 0 deletions tests/test_serverless/test_utils/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,24 @@ def test_validate_rules_not_dict(self):
result = rp_validator.validate(self.raw_input, {"x": "not dict"})
self.assertIn("errors", result)

def test_validate_simple_input(self):
"""
Tests validate with simple input
"""
result = rp_validator.validate(
{"my_input": None}, {"my_input": {"type": str, "required": True}}
)
self.assertIn("errors", result)

def test_validate_none_type(self):
"""
Tests validate with None type
"""
result = rp_validator.validate(
{"my_input": None}, {"my_input": {"type": type(None), "required": True}}
)
self.assertNotIn("errors", result)


if __name__ == "__main__":
unittest.main()
Loading