Upgrade API serialisation code to enable potential context-based serialisation

This commit is contained in:
Ske
2019-12-28 15:52:59 +01:00
parent c80965394d
commit 0f22285824
7 changed files with 149 additions and 144 deletions

View File

@@ -253,6 +253,13 @@ namespace PluralKit
if (input.Trim().Length == 0) return null;
return input;
}
public static string BoundsCheck(this string input, int maxLength, string nameInError)
{
if (input != null && input.Length > maxLength)
throw new PKParseError($"{nameInError} too long ({input.Length} > {maxLength}).");
return input;
}
}
public static class Emojis {