[CHANGE] Update errors to IReadOnlyList

This commit is contained in:
max 2025-02-24 16:07:56 +01:00
parent c6e11efdf2
commit 79d8fcfb8d
2 changed files with 4 additions and 6 deletions

View File

@ -45,9 +45,7 @@ public partial class AuthorityManager
var passwordValidation = await ValidatePasswordAsync(user, password);
if (!passwordValidation.Success)
{
List<ValidationError> errors = [];
errors.AddRange(passwordValidation.Errors);
return AuthorityResult<AuthorityUser>.Failed(errors, ResultFailReason.Validation);
return AuthorityResult<AuthorityUser>.Failed(passwordValidation.Errors, ResultFailReason.Validation);
}
user.PasswordHash = await PasswordHasher.HashPasswordAsync(password);

View File

@ -11,7 +11,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
Reason = ResultFailReason.Unknown;
}
public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, List<ValidationError>? errors = null) : base(success, errorMessage, value, null)
public AuthorityResult(bool success, string errorMessage = "", TResultValue? value = default, ResultFailReason reason = ResultFailReason.None, IReadOnlyList<ValidationError>? errors = null) : base(success, errorMessage, value, null)
{
Success = success;
Message = errorMessage;
@ -20,7 +20,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
ValidationErrors = errors;
}
public ResultFailReason Reason { get; }
public List<ValidationError>? ValidationErrors { get; }
public IReadOnlyList<ValidationError>? ValidationErrors { get; }
public static AuthorityResult<TResultValue> Ok(TResultValue? value) => new AuthorityResult<TResultValue>(true, value:value);
@ -28,7 +28,7 @@ public class AuthorityResult<TResultValue> : Result<TResultValue>
public static AuthorityResult<TResultValue> Error(string errorMessage, ResultFailReason reason = ResultFailReason.Error) =>
new AuthorityResult<TResultValue>(false, errorMessage, reason:reason);
public static AuthorityResult<TResultValue> Failed(List<ValidationError> errors, ResultFailReason reason = ResultFailReason.None)
public static AuthorityResult<TResultValue> Failed(IReadOnlyList<ValidationError> errors, ResultFailReason reason = ResultFailReason.None)
=> new AuthorityResult<TResultValue>(false, errors:errors, reason:reason);
}