"""Syntax-validated Modelo identifiers.``Modelo`` is the generic three-digit identifier/value primitive. Registrymembership and product-scope partitions are resolved at their owning domainboundary rather than while constructing an identifier."""from__future__importannotationsfrompydanticimportGetCoreSchemaHandlerfrompydantic_coreimportCoreSchema,core_schemafrom.errors.hierarchyimportCoreValidationError,pydantic_validation_boundary__all__=["Modelo"]
[docs]classModelo(str):"""Three-digit Modelo identifier; published authority owns membership."""__slots__=()def__new__(cls,value:str)->Modelo:"""Validate and construct one three-digit Modelo identifier."""raw=str(value)iflen(raw)!=3ornotraw.isascii()ornotraw.isdigit():raiseCoreValidationError(f"modelo code must be a three-digit ASCII string, got {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=r"^[0-9]{3}$"),serialization=core_schema.to_string_ser_schema(),)