RepletoryLib.Utilities.Validation
1.0.0
dotnet add package RepletoryLib.Utilities.Validation --version 1.0.0
NuGet\Install-Package RepletoryLib.Utilities.Validation -Version 1.0.0
<PackageReference Include="RepletoryLib.Utilities.Validation" Version="1.0.0" />
<PackageVersion Include="RepletoryLib.Utilities.Validation" Version="1.0.0" />
<PackageReference Include="RepletoryLib.Utilities.Validation" />
paket add RepletoryLib.Utilities.Validation --version 1.0.0
#r "nuget: RepletoryLib.Utilities.Validation, 1.0.0"
#:package RepletoryLib.Utilities.Validation@1.0.0
#addin nuget:?package=RepletoryLib.Utilities.Validation&version=1.0.0
#tool nuget:?package=RepletoryLib.Utilities.Validation&version=1.0.0
RepletoryLib.Utilities.Validation
FluentValidation extensions with South African-specific validators for ID numbers, phone numbers, passports, and more.
Part of the RepletoryLib ecosystem -- standalone, reusable .NET 10 libraries with zero business logic.
Overview
RepletoryLib.Utilities.Validation extends FluentValidation with reusable rule builder extensions for common and South African-specific validation scenarios. It includes validators for SA ID numbers (with Luhn checksum and demographic extraction), phone numbers, passports, company registration numbers, and VAT numbers.
Key Features
- SA ID number validation -- 13-digit Luhn check with date of birth, gender, and citizenship extraction
- SA phone validation -- E.164 and local format support
- SA passport validation -- South African passport number format
- SA company registration -- Company registration number format
- Common validators -- Email, URL, phone, GUID, Base64, strong password, ZAR amounts, dates
- Assembly scanning -- Auto-register all
AbstractValidator<T>implementations
Installation
dotnet add package RepletoryLib.Utilities.Validation
Dependencies
| Package | Type |
|---|---|
RepletoryLib.Common |
RepletoryLib |
FluentValidation |
NuGet (11.11.0) |
FluentValidation.DependencyInjectionExtensions |
NuGet (11.11.0) |
Quick Start
using RepletoryLib.Utilities.Validation;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRepletoryValidation(typeof(Program).Assembly);
Usage Examples
FluentValidation Rule Extensions
using FluentValidation;
using RepletoryLib.Utilities.Validation;
public class CustomerValidator : AbstractValidator<Customer>
{
public CustomerValidator()
{
RuleFor(x => x.Email).ValidEmail();
RuleFor(x => x.Phone).ValidSaPhone();
RuleFor(x => x.IdNumber).ValidSaIdNumber();
RuleFor(x => x.Website).ValidUrl();
RuleFor(x => x.Password).StrongPassword();
RuleFor(x => x.Income).ValidZarAmount();
RuleFor(x => x.DateOfBirth).ValidPastDate();
RuleFor(x => x.AppointmentDate).ValidFutureDate();
}
}
public class CompanyValidator : AbstractValidator<Company>
{
public CompanyValidator()
{
RuleFor(x => x.RegistrationNumber).ValidSaCompanyReg();
RuleFor(x => x.PassportNumber).ValidSaPassport();
RuleFor(x => x.ReferenceId).ValidGuid();
RuleFor(x => x.EncodedData).ValidBase64();
}
}
SA ID Number Validation with Data Extraction
using RepletoryLib.Utilities.Validation;
var result = SaIdNumberValidator.Validate("9501015800087");
if (result.IsValid)
{
Console.WriteLine(result.DateOfBirth); // 1995-01-01
Console.WriteLine(result.Gender); // "Male"
Console.WriteLine(result.CitizenshipStatus); // "SA Citizen"
}
else
{
Console.WriteLine(result.ErrorMessage); // Describes the validation failure
}
Available Validator Extensions
| Extension | Applies To | Description |
|---|---|---|
.ValidEmail() |
string |
Valid email format |
.ValidUrl() |
string |
Valid absolute HTTP/HTTPS URL |
.ValidPhone() |
string |
Generic phone format |
.ValidSaPhone() |
string |
SA phone (E.164, +27, or 0-prefix) |
.ValidSaIdNumber() |
string |
13-digit SA ID with Luhn checksum |
.ValidSaPassport() |
string |
SA passport number format |
.ValidSaCompanyReg() |
string |
SA company registration number |
.StrongPassword() |
string |
Min 8 chars, upper, lower, digit, special |
.ValidZarAmount() |
decimal |
Positive value, max 2 decimal places |
.ValidFutureDate() |
DateTime |
Date must be in the future |
.ValidPastDate() |
DateTime |
Date must be in the past |
.ValidGuid() |
string |
Valid GUID format |
.ValidBase64() |
string |
Valid Base64 string |
Integration with Other RepletoryLib Packages
| Package | Relationship |
|---|---|
RepletoryLib.Common |
Direct dependency |
RepletoryLib.Data.Interceptors |
[ValidateSaIdNumber], [ValidateSaPhone], [ValidateEmail] attributes use similar logic |
RepletoryLib.Utilities.Formatting |
Format validated values for display |
License
This project is licensed under the MIT License.
Copyright (c) 2024-2026 Repletory.
For complete documentation, infrastructure setup, and configuration reference, see the RepletoryLib main repository.
| 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 (>= 11.11.0)
- FluentValidation.DependencyInjectionExtensions (>= 11.11.0)
- RepletoryLib.Common (>= 1.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 |
|---|---|---|
| 1.0.0 | 79 | 3/2/2026 |