Skip to content

dp3.common.types

parse_timedelta_or_passthrough

parse_timedelta_or_passthrough(v)

We pass the value to the native pydantic validator if the value does not match our pattern.

Source code in dp3/common/types.py
def parse_timedelta_or_passthrough(v):
    """
    We pass the value to the native pydantic validator if the value does not match our pattern.
    """
    if v and isinstance(v, str) and time_duration_pattern.match(v):
        return parse_time_duration(v)
    return v

t2_implicity_t1

t2_implicity_t1(v, info: FieldValidationInfo)

If t2 is not specified, it is set to t1.

Source code in dp3/common/types.py
def t2_implicity_t1(v, info: FieldValidationInfo):
    """If t2 is not specified, it is set to t1."""
    v = v or info.data.get("t1")
    return v

t2_after_t1

t2_after_t1(v, info: FieldValidationInfo)

t2 must be after t1

Source code in dp3/common/types.py
def t2_after_t1(v, info: FieldValidationInfo):
    """t2 must be after t1"""
    if info.data.get("t1"):
        assert info.data["t1"] <= v, "'t2' is before 't1'"
    return v