mirror of
https://github.com/chylex/Minecraft-Phantom-Panel.git
synced 2025-04-28 10:15:47 +02:00
24 lines
833 B
C#
24 lines
833 B
C#
using System.Collections.Immutable;
|
|
|
|
namespace Phantom.Server.Services.Users;
|
|
|
|
public abstract record SetUserPasswordError {
|
|
private SetUserPasswordError() {}
|
|
|
|
public sealed record UserNotFound : SetUserPasswordError;
|
|
|
|
public sealed record PasswordIsInvalid(ImmutableArray<PasswordRequirementViolation> Violations) : SetUserPasswordError;
|
|
|
|
public sealed record UnknownError : SetUserPasswordError;
|
|
}
|
|
|
|
public static class SetUserPasswordErrorExtensions {
|
|
public static string ToSentences(this SetUserPasswordError error, string delimiter) {
|
|
return error switch {
|
|
SetUserPasswordError.UserNotFound => "User not found.",
|
|
SetUserPasswordError.PasswordIsInvalid e => string.Join(delimiter, e.Violations.Select(static v => v.ToSentence())),
|
|
_ => "Unknown error."
|
|
};
|
|
}
|
|
}
|