diff --git a/scim2_models/messages/list_response.py b/scim2_models/messages/list_response.py index 41ca070..e2e0d3e 100644 --- a/scim2_models/messages/list_response.py +++ b/scim2_models/messages/list_response.py @@ -60,7 +60,7 @@ def check_results_number( "Field 'total_results' is required but value is missing or null", ) - if obj.total_results > 0 and not obj.resources: + if obj.total_results > 0 and obj.resources is None: raise PydanticCustomError( "no_resource_error", "Field 'resources' is missing or null but 'total_results' is non-zero.", diff --git a/tests/test_list_response.py b/tests/test_list_response.py index e516fa6..24cef07 100644 --- a/tests/test_list_response.py +++ b/tests/test_list_response.py @@ -186,10 +186,7 @@ def test_zero_results(): ListResponse[User].model_validate(payload, scim_ctx=Context.RESOURCE_QUERY_RESPONSE) payload = {"totalResults": 1, "Resources": []} - with pytest.raises(ValidationError): - ListResponse[User].model_validate( - payload, scim_ctx=Context.RESOURCE_QUERY_RESPONSE - ) + ListResponse[User].model_validate(payload, scim_ctx=Context.RESOURCE_QUERY_RESPONSE) payload = {"totalResults": 1} with pytest.raises(ValidationError):