ByteGuard.FileValidator.Extensions.DependencyInjection
10.0.0
Prefix Reserved
See the version list below for details.
dotnet add package ByteGuard.FileValidator.Extensions.DependencyInjection --version 10.0.0
NuGet\Install-Package ByteGuard.FileValidator.Extensions.DependencyInjection -Version 10.0.0
<PackageReference Include="ByteGuard.FileValidator.Extensions.DependencyInjection" Version="10.0.0" />
<PackageVersion Include="ByteGuard.FileValidator.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="ByteGuard.FileValidator.Extensions.DependencyInjection" />
paket add ByteGuard.FileValidator.Extensions.DependencyInjection --version 10.0.0
#r "nuget: ByteGuard.FileValidator.Extensions.DependencyInjection, 10.0.0"
#:package ByteGuard.FileValidator.Extensions.DependencyInjection@10.0.0
#addin nuget:?package=ByteGuard.FileValidator.Extensions.DependencyInjection&version=10.0.0
#tool nuget:?package=ByteGuard.FileValidator.Extensions.DependencyInjection&version=10.0.0
ByteGuard.FileValidator.Extensions.DependencyInjection 
ByteGuard.FileValidator.Extensions.DependencyInjection provides first-class integration of ByteGuard.FileValidator with Microsoft.Extensions.DependencyInjection.
It gives you:
- Extension methods to register the file validator in the DI container
- Easy configuration via appsettings.json or fluent configuration in code
This package is the
Microsoft.Extensions.DependencyInjectionintegration layer. The core validation logic lives inByteGuard.FileValidator.
Getting Started
Installation
This package is published and installed via NuGet.
Reference the package in your project:
dotnet add package ByteGuard.FileValidator.Extensions.DependencyInjection
Usage
Add to DI container
In your Program.cs (or Startup.cs in older projects), register the validator:
using ByteGuard.FileValidator;
using ByteGuard.FileValidator.Extensions.DependencyInjection;
// Using inline configuration
builder.Services.AddFileValidator(options =>
{
options.AllowFileTypes(FileExtensions.Pdf, FileExtensions.Jpg, FileExtensions.Png);
options.FileSizeLimit = ByteSize.MegaBytes(25);
options.ThrowOnInvalidFiles(false);
});
// Using configuration from appsettings.json
builder.Services.AddFileValidator(options => configuration.GetSection("FileValidatorConfiguration").Bind(options));
Injection & Usage
You can then inject FileValidator into your services and other classes.
public class MyService
{
private readonly FileValidator _fileValidator;
public MyService(FileValidator fileValidator)
{
_fileValidator = fileValidator;
}
public bool SaveFile(Stream fileStream, string fileName)
{
var isValid = _fileValidator.IsValidFile(fileName, fileStream);
// ...
}
}
Configuration via appsettings
It's possible to configure the FileValidator through appsettings.json.
ℹ️ As you'll notice below, you can either define the
FileSizeLimitin raw byte size, or use theUnitFileSizeLimitto define the file size in a more human readable format. When both are defined,FileSizeLimitalways wins overUnitFileSizeLimit.
{
"FileValidatorConfiguration": {
"SupportedFileTypes": [ ".pdf", ".jpg", ".png" ],
"FileSizeLimit": 26214400,
"UnitFileSizeLimit": "25MB",
"ThrowExceptionOnInvalidFile": true
}
}
License
ByteGuard.FileValidator.Extensions.DpendencyInjection is Copyright © ByteGuard Contributors - Provided under the MIT license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- ByteGuard.FileValidator (>= 1.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
-
net8.0
- ByteGuard.FileValidator (>= 1.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
-
net9.0
- ByteGuard.FileValidator (>= 1.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.1.0 | 564 | 12/1/2025 |
| 10.0.0 | 108 | 11/29/2025 |
| 10.0.0-dev-01003 | 103 | 11/29/2025 |
| 10.0.0-dev-01002 | 104 | 11/29/2025 |