Coverage for structured_tutorials / models / validators.py: 100%

5 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-21 19:08 +0100

1# Copyright (c) 2025 Mathias Ertl 

2# Licensed under the MIT License. See LICENSE file for details. 

3 

4"""Validators for various models.""" 

5 

6import re 

7from typing import Any 

8 

9 

10def validate_regex(value: Any) -> Any: 

11 """Validate and compile a regular expression.""" 

12 if isinstance(value, str): 

13 return re.compile(value.encode()) 

14 return value # pragma: no cover