validators.time_validator
1import re 2 3 4def validate_process_time(time_str: str) -> bool: 5 """ 6 Validate whether the provided string matches the HH:MM 24-hour time format. 7 8 Accepted formats: 9 - "00:00" through "23:59" 10 - Leading zeros are required (e.g., "09:30" is valid, "9:30" is not) 11 12 :param time_str: A string representing time in HH:MM format. 13 :return: True if the time is valid, False otherwise. 14 """ 15 return bool(re.match(r"^(?:[01]\d|2[0-3]):[0-5]\d$", time_str))
def
validate_process_time(time_str: str) -> bool:
5def validate_process_time(time_str: str) -> bool: 6 """ 7 Validate whether the provided string matches the HH:MM 24-hour time format. 8 9 Accepted formats: 10 - "00:00" through "23:59" 11 - Leading zeros are required (e.g., "09:30" is valid, "9:30" is not) 12 13 :param time_str: A string representing time in HH:MM format. 14 :return: True if the time is valid, False otherwise. 15 """ 16 return bool(re.match(r"^(?:[01]\d|2[0-3]):[0-5]\d$", time_str))
Validate whether the provided string matches the HH:MM 24-hour time format.
Accepted formats:
- "00:00" through "23:59"
- Leading zeros are required (e.g., "09:30" is valid, "9:30" is not)
Parameters
- time_str: A string representing time in HH: MM format.
Returns
True if the time is valid, False otherwise.