@@ -521,20 +521,14 @@ class GoogleCloudHealthcareURL:
521521
522522 def __post_init__ (self ) -> None :
523523 """Performs input sanity checks."""
524- if _REGEX_ID_1 .fullmatch (self .project_id ) is None :
525- raise ValueError (_CHC_API_ERROR_TMPL .format (
526- attribute = 'project_id' , regex = _REGEX_ID_1 , value = self .project_id ))
527- if _REGEX_ID_1 .fullmatch (self .location ) is None :
528- raise ValueError (_CHC_API_ERROR_TMPL .format (
529- attribute = 'location' , regex = _REGEX_ID_1 , value = self .location ))
530- if _REGEX_ID_2 .fullmatch (self .dataset_id ) is None :
531- raise ValueError (_CHC_API_ERROR_TMPL .format (
532- attribute = 'dataset_id' , regex = _REGEX_ID_2 , value = self .dataset_id ))
533- if _REGEX_ID_2 .fullmatch (self .dicom_store_id ) is None :
534- raise ValueError (_CHC_API_ERROR_TMPL .format (
535- attribute = 'dicom_store_id' ,
536- regex = _REGEX_ID_2 ,
537- value = self .dicom_store_id ))
524+ for regex , attribute , value in (
525+ (_REGEX_ID_1 , 'project_id' , self .project_id ),
526+ (_REGEX_ID_1 , 'location' , self .location ),
527+ (_REGEX_ID_2 , 'dataset_id' , self .dataset_id ),
528+ (_REGEX_ID_2 , 'dicom_store_id' , self .dicom_store_id )):
529+ if regex .fullmatch (value ) is None :
530+ raise ValueError (_CHC_API_ERROR_TMPL .format (
531+ attribute = attribute , regex = regex , value = value ))
538532
539533 def __str__ (self ) -> str :
540534 """Returns a string URL for use as :py:attr:`URI.base_url`.
0 commit comments