mirror of
https://github.com/hmaxnl/DotBased.git
synced 2025-04-04 21:51:26 +02:00
[CHANGE] Update errors to IReadOnlyList
This commit is contained in:
parent
c6e11efdf2
commit
79d8fcfb8d
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user