Coverage for src/backend/InvenTree/report/validators.py: 82%

9 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 17:47 +0000

1"""Validators for report models.""" 

2 

3from django.core.exceptions import ValidationError 

4 

5import report.helpers 

6 

7 

8def validate_report_model_type(value): 

9 """Ensure that the selected model type is valid.""" 

10 model_options = [el[0] for el in report.helpers.report_model_options()] 

11 

12 if value not in model_options: 12 ↛ 13line 12 didn't jump to line 13 because the condition on line 12 was never true

13 raise ValidationError('Not a valid model type') 

14 

15 

16def validate_filters(value: str, model=None) -> dict: 

17 """Validate that the provided model filters are valid.""" 

18 from InvenTree.helpers import validateFilterString 

19 

20 return validateFilterString(value, model=model)