Skip to content

Commit f9aefdc

Browse files
committed
Add validation for TemperatureDecimalDigits (0-2) in GeneralSettings.Validate()
1 parent bc726ea commit f9aefdc

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

ImmichFrame.WebApi/Helpers/Config/ServerSettingsV1.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ class GeneralSettingsV1Adapter(ServerSettingsV1 _delegate) : IGeneralSettings
128128
public string Layout => _delegate.Layout;
129129
public string Language => _delegate.Language;
130130

131-
public void Validate() { }
131+
public void Validate()
132+
{
133+
if (TemperatureDecimalDigits < 0 || TemperatureDecimalDigits > 2)
134+
{
135+
throw new ArgumentOutOfRangeException(nameof(TemperatureDecimalDigits),
136+
TemperatureDecimalDigits,
137+
"TemperatureDecimalDigits must be between 0 and 2.");
138+
}
139+
}
132140
}
133141
}

ImmichFrame.WebApi/Models/ServerSettings.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,15 @@ public class GeneralSettings : IGeneralSettings, IConfigSettable
7272
public string? Webhook { get; set; }
7373
public string? AuthenticationSecret { get; set; }
7474

75-
public void Validate() { }
75+
public void Validate()
76+
{
77+
if (TemperatureDecimalDigits < 0 || TemperatureDecimalDigits > 2)
78+
{
79+
throw new ArgumentOutOfRangeException(nameof(TemperatureDecimalDigits),
80+
TemperatureDecimalDigits,
81+
"TemperatureDecimalDigits must be between 0 and 2.");
82+
}
83+
}
7684
}
7785

7886
public class ServerAccountSettings : IAccountSettings, IConfigSettable

0 commit comments

Comments
 (0)