"""Syntax-validated tax-domain identifiers.Catalogue membership belongs to the published registry authority. This moduledefines only the stable wire identifier shape needed during its reconstruction."""from__future__importannotationsimportrefrompydanticimportGetCoreSchemaHandlerfrompydantic_coreimportCoreSchema,core_schemafrom.errors.hierarchyimportCoreValidationError,pydantic_validation_boundary__all__=["TaxDomain"]_TAX_DOMAIN_PATTERN=re.compile(r"^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$")
[docs]classTaxDomain(str):"""Open tax-domain identifier whose membership is authority-validated."""__slots__=()def__new__(cls,value:str)->TaxDomain:"""Validate and construct one syntax-only tax-domain identifier."""raw=str(value)if_TAX_DOMAIN_PATTERN.fullmatch(raw)isNone:raiseCoreValidationError(f"invalid tax-domain identifier: {value!r}")returnstr.__new__(cls,raw)@propertydefvalue(self)->str:"""Return the stable string representation used on the wire."""returnstr(self)@classmethoddef__get_pydantic_core_schema__(cls,source_type:type[object],handler:GetCoreSchemaHandler,)->CoreSchema:"""Validate from and serialize to the canonical JSON string shape."""delsource_type,handlerreturncore_schema.no_info_after_validator_function(pydantic_validation_boundary(cls),core_schema.str_schema(pattern=_TAX_DOMAIN_PATTERN.pattern),serialization=core_schema.to_string_ser_schema(),)