Coverage for src / questions / validators / nullable.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-11-21 16:36 +0000

1from prompt_toolkit.validation import ValidationError 

2 

3 

4def validate(value, schema): 

5 """ 

6 Return { value to use, stop (True/False) } 

7 

8 If stop is True, the rest of the validators are skipped. 

9 """ 

10 # ctrl-d gives us a None, if value is not None, 

11 # we're not concerned 

12 if value is not None: 

13 return value, False 

14 

15 nullable = schema.get("nullable", False) 

16 if nullable: 

17 return None, True 

18 raise ValidationError(message="Answer is required")