2121from pydantic_core .core_schema import ValidationInfo
2222from typing_extensions import Annotated
2323
24+ from .constraints import TYPES_ID_MAX_LENGTH , TYPES_STRING_ALLOW_EMPTY_STR
2425from .fhirabstractmodel import FHIRAbstractModel
2526
2627__author__ = "Md Nazrul Islam"
@@ -330,7 +331,7 @@ class StringModel(BaseModel):
330331 ```
331332 """
332333
333- allow_empty_str : bool = False
334+ allow_empty_str = TYPES_STRING_ALLOW_EMPTY_STR
334335 __visit_name__ = "string"
335336
336337 def __iter__ (self ) -> typing .Iterator [BaseMetadata ]:
@@ -357,6 +358,10 @@ def to_string(value):
357358 assert isinstance (value , bytes )
358359 return value .decode ()
359360
361+ def __hash__ (self ) -> int :
362+ """ """
363+ return hash (self .__class__ )
364+
360365
361366@dataclasses .dataclass (frozen = True , ** SLOTS )
362367class Code (GroupedMetadata ):
@@ -381,6 +386,9 @@ def to_string(value):
381386 assert isinstance (value , str )
382387 return value
383388
389+ def __hash__ (self ) -> int :
390+ return hash (self .__class__ )
391+
384392
385393@dataclasses .dataclass (frozen = True , ** SLOTS )
386394class Id (GroupedMetadata ):
@@ -390,8 +398,7 @@ class Id(GroupedMetadata):
390398 (This might be an integer, an un-prefixed OID, UUID or any other identifier
391399 pattern that meets these constraints.)
392400
393- But it is possible to change the default behaviour by using configure_constraints()
394- method!
401+ But it is possible to change the default behaviour by patching constraint.TYPES_ID_MAX_LENGTH value!
395402
396403 There are a lots of discussion about ``Resource.Id`` length of value.
397404 1. https://bit.ly/360HksL
@@ -402,7 +409,7 @@ class Id(GroupedMetadata):
402409
403410 pattern = r"^[A-Za-z0-9\-.]+$"
404411 min_length = 1
405- max_length = 64
412+ max_length = TYPES_ID_MAX_LENGTH
406413 __visit_name__ = "id"
407414
408415 def __iter__ (self ) -> typing .Iterator [BaseMetadata ]:
@@ -966,7 +973,7 @@ def to_string(cls, value):
966973FHIR_PRIMITIVES_MAPS [BooleanType ] = "boolean"
967974
968975# string
969- StringType = Annotated [str , String (allow_empty_str = False )]
976+ StringType = Annotated [str , String ()]
970977FHIR_PRIMITIVES_MAPS [StringType ] = "string"
971978
972979# base64Binary
0 commit comments