@@ -67,13 +67,6 @@ class Sekolah(BaseModel):
6767 checksum : Optional [str ] = Field (default = None , description = "SHA-256 hash computed with certain fields excluded" )
6868 createdAt : datetime = Field (default_factory = _utc_now , description = "UTC timestamp when the document was created" )
6969
70- @field_validator ("noTelefon" , "noFax" , mode = "before" )
71- def empty_to_none (cls , value ):
72- if value is None :
73- return None
74- text = str (value ).strip ().upper ()
75- return None if text in MISSING_VALUES else value
76-
7770 @field_validator ("kodSekolah" , mode = "before" )
7871 def validate_kod_sekolah (cls , value : str | None ) -> str :
7972 text = "" if value is None else str (value ).strip ()
@@ -171,6 +164,21 @@ def normalize_negeri(cls, value):
171164 except ValueError as exc :
172165 raise ValueError (f"Invalid negeri value: { text } " ) from exc
173166
167+ @field_validator ("noTelefon" , "noFax" , mode = "before" )
168+ def normalize_phone (cls , value ):
169+ if value is None :
170+ return None
171+
172+ text = str (value ).strip ()
173+
174+ if not text or text .upper () in MISSING_VALUES :
175+ return None
176+
177+ if text .startswith ("0" ) or text .startswith ("+" ):
178+ return text
179+
180+ return "0" + text
181+
174182 model_config = {
175183 "populate_by_name" : True ,
176184 "extra" : "ignore" ,
0 commit comments