-
Notifications
You must be signed in to change notification settings - Fork 129
Closed
Labels
good first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needed
Description
Hi! I was thinking of improving the approach by initializing the ValidationError class.
Instead of:
if (await _repository.ExistsAsync(request.Email))
{
return Result.Invalid(new List<ValidationError>
{
new ValidationError
{
ErrorMessage = "The email address provided is already in use"
}
});
}To do this:
if (await _repository.ExistsAsync(request.Email))
{
return Result.Invalid(ValidationError.Create(new ValidationError(""));
}
public class ValidationError
{
public ValidationError(string errorMessage)
{
ErrorMessage = errorMessage;
}
public ValidationError(string identifier, string errorMessage, string errorCode, ValidationSeverity severity)
{
Identifier = identifier;
ErrorMessage = errorMessage;
ErrorCode = errorCode;
Severity = severity;
}
public ValidationError()
{
}
public string Identifier { get; set; }
public string ErrorMessage { get; set; }
public string ErrorCode { get; set; }
public ValidationSeverity Severity { get; set; }
public static IList<ValidationError> Create(params ValidationError[] errors) => new List<ValidationError>(errors);
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershacktoberfesthelp wantedExtra attention is neededExtra attention is needed