PosInformatique.Foundations.People.FluentValidation 1.1.0

Prefix Reserved
There is a newer prerelease version of this package available.
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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PosInformatique.Foundations.People.FluentValidation" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.People.FluentValidation" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.People.FluentValidation" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PosInformatique.Foundations.People.FluentValidation --version 1.1.0
                    
#r "nuget: PosInformatique.Foundations.People.FluentValidation, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PosInformatique.Foundations.People.FluentValidation@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PosInformatique.Foundations.People.FluentValidation&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.People.FluentValidation&version=1.1.0
                    
Install as a Cake Tool

PosInformatique.Foundations.People.FluentValidation

NuGet version NuGet downloads

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 FirstName and LastName value objects
  • Clear and consistent error messages

null values are accepted (combine with NotNull() 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 FirstName and LastName within 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
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

1.0.0
 - Initial release with the support FluentValidation for the validation of FirstName and LastName value objects.