File size: 749 Bytes
c08424b
 
 
 
 
2bfc495
c08424b
 
 
 
 
 
 
 
 
 
 
 
2bfc495
c08424b
 
2bfc495
c08424b
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""
Flare – Parameter Validation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Basit tip + regex kontrolü; Spark veya harici lib ile zenginleştirilebilir.
"""

import re
from typing import Any
from config_provider import ParameterConfig

def validate(value: str, param: ParameterConfig) -> bool:
    t = param.canonical_type()
    if t == "int":
        if not value.isdigit(): return False
    elif t == "float":
        try: float(value)
        except ValueError: return False
    elif t in ("str", "string"):
        pass
    elif t == "bool":
        if value.lower() not in ("true","false","1","0","evet","hayır"): return False

    if param.validation_regex and not re.fullmatch(param.validation_regex, value, re.I):
        return False
    return True