DLoizides.Validation
1.1.0
See the version list below for details.
dotnet add package DLoizides.Validation --version 1.1.0
NuGet\Install-Package DLoizides.Validation -Version 1.1.0
<PackageReference Include="DLoizides.Validation" Version="1.1.0" />
<PackageVersion Include="DLoizides.Validation" Version="1.1.0" />
<PackageReference Include="DLoizides.Validation" />
paket add DLoizides.Validation --version 1.1.0
#r "nuget: DLoizides.Validation, 1.1.0"
#:package DLoizides.Validation@1.1.0
#addin nuget:?package=DLoizides.Validation&version=1.1.0
#tool nuget:?package=DLoizides.Validation&version=1.1.0
Validation.Defaults
Shared FluentValidation rules and constants for FastEndpoints services.
Installation
dotnet add package DLoizides.Validation
Usage
Validation Extensions
using FluentValidation;
using Validation.Defaults.Rules;
public class CreateMenuValidator : AbstractValidator<CreateMenuRequest>
{
public CreateMenuValidator()
{
RuleFor(x => x.Id).NotEmptyGuid();
RuleFor(x => x.Name).NotEmpty().MaximumLength(ValidationLimits.MaxNameLength);
RuleFor(x => x.Color).ValidHexColor();
RuleFor(x => x.Url).ValidUrl();
RuleFor(x => x.Page).ValidPageNumber();
RuleFor(x => x.PageSize).ValidPageSize();
}
}
Available Extensions
| Extension | Description |
|---|---|
.NotEmptyGuid() |
Rejects Guid.Empty |
.ValidHexColor() |
Accepts #RGB, #RRGGBB, #RRGGBBAA |
.ValidUrl() |
Validates well-formed HTTP/HTTPS URLs |
.MustBeHttpsUrl() |
Absolute https:// URL with a host only; rejects http:, javascript:, data:, relative and protocol-relative URLs, whitespace |
.ValidPhotoOffset() |
double? within -60..60 (percent), finite; null allowed |
.ValidPhotoScale() |
double? within 0.5..3, finite; null allowed |
.ValidEmail() |
Validates email format |
.ValidPageNumber() |
Page >= 1 |
.ValidPageSize() |
1 ⇐ pageSize ⇐ 100 |
.ValidSkip() |
skip >= 0 |
Constants
using Validation.Defaults.Constants;
// Field length limits
ValidationLimits.MaxNameLength // 200
ValidationLimits.MaxDescriptionLength // 2000
ValidationLimits.MaxUrlLength // 2048
ValidationLimits.MaxEmailLength // 254
ValidationLimits.MaxPhoneLength // 20
ValidationLimits.MaxColorLength // 9 (#RRGGBBAA)
ValidationLimits.MaxPageSize // 100
Photo framing
using Validation.Defaults.Abstractions;
using Validation.Defaults.Validators;
public sealed record Framing(double? X, double? Y, double? Scale) : IPhotoFraming;
RuleFor(x => x.Framing!).SetValidator(new PhotoFramingValidator<Framing>())
.When(x => x.Framing is not null);
Bounds are public consts in PhotoFramingLimits (MinOffsetPercent -60, MaxOffsetPercent 60,
MinScale 0.5, MaxScale 3). Keep them equal to the renderer's clamp so an accepted value is
never silently altered on the page.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- FluentValidation (>= 12.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DLoizides.Validation:
| Package | Downloads |
|---|---|
|
Dloizides.ServiceDefaults.FastEndpoints
Add-on to Dloizides.ServiceDefaults: FastEndpoints with the house route prefix and JSON settings, plus the Keycloak OAuth2 PKCE Swagger UI served under its own docs Content-Security-Policy. |
GitHub repositories
This package is not used by any popular GitHub repositories.