-
-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1692 from exceptionless/feature/shadcn-forms
Use shadcn forms
- Loading branch information
Showing
94 changed files
with
3,169 additions
and
1,914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Exceptionless.Core/Validation/MiniValidationValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Text; | ||
using MiniValidation; | ||
|
||
namespace Exceptionless.Core.Validation; | ||
|
||
public class MiniValidationValidator(IServiceProvider serviceProvider) | ||
{ | ||
public ValueTask<(bool IsValid, IDictionary<string, string[]> Errors)> ValidateAsync<T>(T instance) | ||
{ | ||
return MiniValidator.TryValidateAsync(instance, serviceProvider, recurse: true); | ||
} | ||
|
||
public async Task ValidateAndThrowAsync<T>(T instance) | ||
{ | ||
(bool isValid, var errors) = await ValidateAsync(instance); | ||
if (isValid) | ||
return; | ||
|
||
throw new MiniValidatorException("Please correct the specified errors and try again", errors); | ||
} | ||
} | ||
|
||
public class MiniValidatorException(string message, IDictionary<string, string[]> errors) : Exception(message) | ||
{ | ||
public IDictionary<string, string[]> Errors { get; } = errors; | ||
|
||
public string FormattedErrorMessages() | ||
{ | ||
var errorMessages = new StringBuilder(); | ||
errorMessages.AppendLine(Message); | ||
foreach (var error in Errors) | ||
{ | ||
errorMessages.Append("- ").Append(error.Key).Append(": "); | ||
errorMessages.AppendJoin(", ", error.Value); | ||
errorMessages.AppendLine(); | ||
} | ||
|
||
return errorMessages.ToString(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.