https://github.com/chataize/perfect-email
Easy-to-use, high-performance email validator for C# .NET 8.0 with custom attribute and disposable domain detection.
https://github.com/chataize/perfect-email
asp-net-core attribute chataize checker csharp detection disposable-email disposable-mailbox dotnet dotnet-core email email-address email-checker email-validation email-validator library model-validation nuget validation validator
Last synced: 10 months ago
JSON representation
Easy-to-use, high-performance email validator for C# .NET 8.0 with custom attribute and disposable domain detection.
- Host: GitHub
- URL: https://github.com/chataize/perfect-email
- Owner: chataize
- License: gpl-3.0
- Created: 2024-03-30T10:39:36.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T20:28:07.000Z (11 months ago)
- Last Synced: 2025-03-19T21:36:43.549Z (11 months ago)
- Topics: asp-net-core, attribute, chataize, checker, csharp, detection, disposable-email, disposable-mailbox, dotnet, dotnet-core, email, email-address, email-checker, email-validation, email-validator, library, model-validation, nuget, validation, validator
- Language: C#
- Homepage: https://www.chataize.com
- Size: 110 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Perfect Email
An easy-to-use, high-performance email validator for C# .NET 9.0 with custom attribute and disposable domain detection.
## Installation
### .NET CLI
```bash
dotnet add package ChatAIze.PerfectEmail
```
### Package Manager Console
```powershell
Install-Package ChatAIze.PerfectEmail
```
## Usage
```cs
using ChatAIze.PerfectEmail;
bool isValidEmail = EmailValidator.IsValidEmail("someone@example.com");
Console.WriteLine(isValidEmail); // true
bool isDisposableEmail = DisposableEmailDetector.IsDisposableEmail("someone@0-mail.com");
Console.WriteLine(isDisposableEmail); // true
bool isDisposableEmailDomain = DisposableEmailDetector.IsDisposableEmailDomain("0-mail.com");
Console.WriteLine(isDisposableEmailDomain); // true
```
## Attribute Usage
The `Email` attribute performs address validation when the model is submitted. However, it does not check for disposable domains. An HTTP `400 Bad Request` status code is returned by default.
```cs
using ChatAIze.PerfectEmail;
namespace ChatAIze.ExampleAPI.Models;
public record AccountCreationRequest
{
[Email]
public required string Email { get; init; }
public required string Password { get; init; }
}
```
```cs
using ChatAIze.ExampleAPI.Models;
using Microsoft.AspNetCore.Mvc;
namespace ChatAIze.ExampleAPI.Controllers;
[ApiController]
[Route("api/[controller]")]
public sealed class AccountsController : ControllerBase
{
[HttpPost]
public IActionResult CreateAccount(AccountCreationRequest request)
{
Console.WriteLine($"Creating account for {request.Email}");
return NoContent();
}
}
```