File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444from sqlmesh .core .user import User
4545from sqlmesh .utils .date import to_timestamp , now
4646from sqlmesh .utils .errors import ConfigError
47- from sqlmesh .utils .pydantic import model_validator , field_validator
47+ from sqlmesh .utils .pydantic import model_validator
48+
49+
50+ def validate_no_past_ttl (v : str ) -> str :
51+ current_time = now ()
52+ if to_timestamp (v , relative_base = current_time ) < to_timestamp (current_time ):
53+ raise ValueError (
54+ f"TTL '{ v } ' is in the past. Please specify a relative time in the future. Ex: `in 1 week` instead of `1 week`."
55+ )
56+ return v
57+
58+
59+ def gateways_ensure_dict (value : t .Dict [str , t .Any ]) -> t .Dict [str , t .Any ]:
60+ try :
61+ if not isinstance (value , GatewayConfig ):
62+ GatewayConfig .parse_obj (value )
63+ return {"" : value }
64+ except Exception :
65+ return value
66+
67+
68+ def validate_regex_key_dict (value : t .Dict [str | re .Pattern , t .Any ]) -> t .Dict [re .Pattern , t .Any ]:
69+ return compile_regex_mapping (value )
70+
4871
4972
5073def validate_no_past_ttl (v : str ) -> str :
You can’t perform that action at this time.
0 commit comments