lint/fixes, add group patch validation
This commit is contained in:
parent
bc2c198a82
commit
c472a7f6df
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -35,12 +35,20 @@ namespace PluralKit.Core
|
|||||||
|
|
||||||
public new void AssertIsValid()
|
public new void AssertIsValid()
|
||||||
{
|
{
|
||||||
if (Icon.Value != null && !MiscUtils.TryMatchUri(Icon.Value, out var avatarUri))
|
if (Name.IsPresent)
|
||||||
throw new ValidationError("icon");
|
AssertValid(Name.Value, "name", Limits.MaxGroupNameLength);
|
||||||
if (BannerImage.Value != null && !MiscUtils.TryMatchUri(BannerImage.Value, out var bannerImage))
|
if (DisplayName.Value != null)
|
||||||
throw new ValidationError("banner");
|
AssertValid(DisplayName.Value, "display_name", Limits.MaxGroupNameLength);
|
||||||
if (Color.Value != null && (!Regex.IsMatch(Color.Value, "^[0-9a-fA-F]{6}$")))
|
if (Description.Value != null)
|
||||||
throw new ValidationError("color");
|
AssertValid(Description.Value, "description", Limits.MaxDescriptionLength);
|
||||||
|
if (Icon.Value != null)
|
||||||
|
AssertValid(Icon.Value, "icon", Limits.MaxUriLength,
|
||||||
|
s => MiscUtils.TryMatchUri(s, out var avatarUri));
|
||||||
|
if (BannerImage.Value != null)
|
||||||
|
AssertValid(BannerImage.Value, "banner", Limits.MaxUriLength,
|
||||||
|
s => MiscUtils.TryMatchUri(s, out var bannerUri));
|
||||||
|
if (Color.Value != null)
|
||||||
|
AssertValid(Color.Value, "color", "^[0-9a-fA-F]{6}$");
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ namespace PluralKit.Core
|
|||||||
public new void AssertIsValid()
|
public new void AssertIsValid()
|
||||||
{
|
{
|
||||||
if (Name.IsPresent)
|
if (Name.IsPresent)
|
||||||
AssertValid(Name.Value, "display_name", Limits.MaxMemberNameLength);
|
AssertValid(Name.Value, "name", Limits.MaxMemberNameLength);
|
||||||
if (DisplayName.Value != null)
|
if (DisplayName.Value != null)
|
||||||
AssertValid(DisplayName.Value, "display_name", Limits.MaxMemberNameLength);
|
AssertValid(DisplayName.Value, "display_name", Limits.MaxMemberNameLength);
|
||||||
if (AvatarUrl.Value != null)
|
if (AvatarUrl.Value != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user