Skip to content

Commit 9f48b27

Browse files
committed
Add basic model validator to convert 'mkdir_chmod' string into an int
1 parent df8d58f commit 9f48b27

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/murfey/util/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ def validate_software_versions(cls, v: dict[str, Any]) -> dict[str, str]:
153153
# Let it validate and fail as-is
154154
return v
155155

156+
@field_validator("mkdir_chmod", mode="before")
157+
@classmethod
158+
def parse_octal_int(cls, value):
159+
# Attempt to parse the string as an octal int
160+
if isinstance(value, str):
161+
return int(value, 8)
162+
# Return value as-is otherwise
163+
return value
164+
156165

157166
@lru_cache(maxsize=1)
158167
def machine_config_from_file(

0 commit comments

Comments
 (0)