PosInformatique.Foundations.People.FluentValidation
1.1.0
Prefix Reserved
See the version list below for details.
dotnet add package PosInformatique.Foundations.People.FluentValidation --version 1.1.0
NuGet\Install-Package PosInformatique.Foundations.People.FluentValidation -Version 1.1.0
<PackageReference Include="PosInformatique.Foundations.People.FluentValidation" Version="1.1.0" />
<PackageVersion Include="PosInformatique.Foundations.People.FluentValidation" Version="1.1.0" />
<PackageReference Include="PosInformatique.Foundations.People.FluentValidation" />
paket add PosInformatique.Foundations.People.FluentValidation --version 1.1.0
#r "nuget: PosInformatique.Foundations.People.FluentValidation, 1.1.0"
#:package PosInformatique.Foundations.People.FluentValidation@1.1.0
#addin nuget:?package=PosInformatique.Foundations.People.FluentValidation&version=1.1.0
#tool nuget:?package=PosInformatique.Foundations.People.FluentValidation&version=1.1.0
PosInformatique.Foundations.People.FluentValidation
Introduction
This package provides FluentValidation extensions for validating first names and last names using the
FirstName and LastName value objects from PosInformatique.Foundations.People.
It simplifies the integration of robust name validation into your FluentValidation rules, ensuring that string properties conform to the defined business rules for first and last names.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.People.FluentValidation
Features
- FluentValidation extension for first name and last name validation based on the business rules of the PosInformatique.Foundations.People package.
- Uses the same parsing and validation rules as the
FirstNameandLastNamevalue objects - Clear and consistent error messages
nullvalues are accepted (combine withNotNull()validator to forbid nulls)
Use cases
- Validation: Ensure that user inputs for first and last names adhere to your domain's business rules.
- Type safety: Leverage the strong typing of
FirstNameandLastNamewithin your validation logic. - Consistency: Apply a single, robust name validation logic across all projects using FluentValidation.
Examples
Validating FirstName
public class PersonValidator : AbstractValidator<Person>
{
public PersonValidator()
{
// FirstName must be a valid FirstName (e.g., "John", "Jean-Pierre")
// Null values are allowed by default. Use NotNull() to disallow.
RuleFor(x => x.FirstName).MustBeFirstName();
// Example with NotNull()
RuleFor(x => x.FirstName)
.NotNull()
.MustBeFirstName();
}
}
public class Person
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
}
// Usage
var validator = new PersonValidator();
// Valid
var result1 = validator.Validate(new Person { FirstName = "John", LastName = "DOE" }); // IsValid: true
// Invalid (contains invalid character)
var result2 = validator.Validate(new Person { FirstName = "John_123", LastName = "DOE" }); // IsValid: false
// Invalid (too long)
var result3 = validator.Validate(new Person { FirstName = new string('A', 51), LastName = "DOE" }); // IsValid: false
// Null (valid by default for MustBeFirstName)
var result4 = validator.Validate(new Person { FirstName = null, LastName = "DOE" }); // IsValid: true
// Null (invalid if NotNull() is used)
var validatorNotNull = new PersonValidator();
validatorNotNull.RuleFor(x => x.FirstName).NotNull().MustBeFirstName();
var result5 = validatorNotNull.Validate(new Person { FirstName = null, LastName = "DOE" }); // IsValid: false
Validating LastName
public class PersonValidator : AbstractValidator<Person>
{
public PersonValidator()
{
// LastName must be a valid LastName (e.g., "DOE", "SMITH-JOHNSON")
// Null values are allowed by default. Use NotNull() to disallow.
RuleFor(x => x.LastName).MustBeLastName();
// Example with NotNull()
RuleFor(x => x.LastName)
.NotNull()
.MustBeLastName();
}
}
public class Person
{
public string? FirstName { get; set; }
public string? LastName { get; set; }
}
// Usage
var validator = new PersonValidator();
// Valid
var result1 = validator.Validate(new Person { FirstName = "John", LastName = "DOE" }); // IsValid: true
// Invalid (contains invalid character)
var result2 = validator.Validate(new Person { FirstName = "John", LastName = "DOE_123" }); // IsValid: false
// Invalid (too long)
var result3 = validator.Validate(new Person { FirstName = "John", LastName = new string('A', 51) }); // IsValid: false
// Null (valid by default for MustBeLastName)
var result4 = validator.Validate(new Person { FirstName = "John", LastName = null }); // IsValid: true
// Null (invalid if NotNull() is used)
var validatorNotNull = new PersonValidator();
validatorNotNull.RuleFor(x => x.LastName).NotNull().MustBeLastName();
var result5 = validatorNotNull.Validate(new Person { FirstName = "John", LastName = null }); // IsValid: false
Links
| 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
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.People (>= 1.1.0)
-
net8.0
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.People (>= 1.1.0)
-
net9.0
- FluentValidation (>= 12.0.0)
- PosInformatique.Foundations.People (>= 1.1.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 |
|---|---|---|
| 1.2.0-rc.1 | 53 | 3/31/2026 |
| 1.1.0 | 90 | 3/30/2026 |
| 1.1.0-rc.3 | 57 | 3/27/2026 |
| 1.1.0-rc.2 | 57 | 1/26/2026 |
| 1.1.0-rc.1 | 81 | 1/23/2026 |
| 1.0.0 | 470 | 11/19/2025 |
| 1.0.0-rc.4 | 385 | 11/19/2025 |
| 1.0.0-rc.3 | 374 | 11/18/2025 |
| 1.0.0-rc.2 | 377 | 11/18/2025 |
| 1.0.0-rc.1 | 377 | 11/18/2025 |
1.0.0
- Initial release with the support FluentValidation for the validation of FirstName and LastName value objects.