refactor(backend): use explicit types instead of var by default

This commit is contained in:
sam 2024-12-08 15:07:25 +01:00
parent bc7fd6d804
commit 649988db25
Signed by: sam
GPG key ID: B4EF20DDE721CAA1
52 changed files with 506 additions and 420 deletions

View file

@ -29,6 +29,7 @@ public static partial class ValidationUtils
var errors = new List<(string, ValidationError?)>();
if (preferences.Count > MaxCustomPreferences)
{
errors.Add(
(
"custom_preferences",
@ -40,20 +41,29 @@ public static partial class ValidationUtils
)
)
);
}
if (preferences.Count > 50)
return errors;
foreach (var (p, i) in preferences.Select((p, i) => (p, i)))
foreach (
(UsersController.CustomPreferenceUpdate? p, int i) in preferences.Select(
(p, i) => (p, i)
)
)
{
if (!BootstrapIcons.IsValid(p.Icon))
{
errors.Add(
(
$"custom_preferences.{i}.icon",
ValidationError.DisallowedValueError("Invalid icon name", [], p.Icon)
)
);
}
if (p.Tooltip.Length is 1 or > MaxPreferenceTooltipLength)
{
errors.Add(
(
$"custom_preferences.{i}.tooltip",
@ -65,6 +75,7 @@ public static partial class ValidationUtils
)
)
);
}
}
return errors;