SAValidation.Common
1.0.4
dotnet add package SAValidation.Common --version 1.0.4
NuGet\Install-Package SAValidation.Common -Version 1.0.4
<PackageReference Include="SAValidation.Common" Version="1.0.4" />
<PackageVersion Include="SAValidation.Common" Version="1.0.4" />
<PackageReference Include="SAValidation.Common" />
paket add SAValidation.Common --version 1.0.4
#r "nuget: SAValidation.Common, 1.0.4"
#:package SAValidation.Common@1.0.4
#addin nuget:?package=SAValidation.Common&version=1.0.4
#tool nuget:?package=SAValidation.Common&version=1.0.4
SAValidation.Common
Shared utilities for South African validation libraries.
NuGet: https://www.nuget.org/packages/SAValidation.Common/ GitHub: https://github.com/NuGetPackagesPGLN/SAValidation
Installation
dotnet add package SAValidation.Common
Features
- String Extensions: Clean numbers, extract digits, safe substring operations
- Guard Clauses: Defensive programming helpers
- Shared Utilities: Common functionality used by all SAValidation packages
- Regex Helpers: Pre-compiled regex for optimal performance
- Null Safety: Built with nullable reference types
Usage Examples
Clean a phone number (remove spaces, dashes, parentheses)
using SAValidation.Common;
string dirty = "082 555 1234"; string clean = dirty.CleanNumber(); // Result: "0825551234"
string withDashes = "082-555-1234"; string clean2 = withDashes.CleanNumber(); // Result: "0825551234"
string withParentheses = "(082) 555-1234"; string clean3 = withParentheses.CleanNumber(); // Result: "0825551234"
Extract only digits from any string
string mixed = "+27 (82) 555-1234"; string digits = mixed.ExtractDigits(); // Result: "27825551234"
string letters = "ABC123DEF456"; string digits2 = letters.ExtractDigits(); // Result: "123456"
Check if string contains only digits
string numbers = "123456"; bool isDigits = numbers.IsAllDigits(); // true
string mixed = "123abc"; bool isDigits2 = mixed.IsAllDigits(); // false
Check if string starts with any prefix
string phone = "0825551234"; bool startsWithMobile = phone.StartsWithAny("082", "083", "084"); // Result: true (starts with 082)
string landline = "0115551234"; bool startsWithMobile2 = landline.StartsWithAny("082", "083", "084"); // Result: false
Safe substring with bounds checking
string text = "0825551234";
// Normal usage string sub1 = text.SafeSubstring(0, 3); // "082"
// Bounds checking - won't throw exception string sub2 = text.SafeSubstring(8, 10); // "34" (only takes available characters)
string empty = null; string sub3 = empty.SafeSubstring(0, 5); // "" (handles null safely)
API Reference
StringExtensions Methods
| Method | Description | Example |
|---|---|---|
| CleanNumber() | Removes spaces, dashes, parentheses, dots | "082 555 1234" → "0825551234" |
| ExtractDigits() | Returns only digits from string | "+27 (82) 555-1234" → "27825551234" |
| IsAllDigits() | Checks if string contains only digits | "123456" → true |
| StartsWithAny() | Checks if string starts with any of the provided prefixes | "0825551234" with ["082","083"] → true |
| SafeSubstring() | Gets substring with bounds checking | "0825551234", 8, 10 → "34" |
Guard Class Methods
| Method | Description |
|---|---|
| AgainstNullOrWhiteSpace() | Throws if string is null or whitespace |
| AgainstOutOfRange() | Throws if value is outside specified range |
Contributing
Contributions are welcome! Please submit pull requests to the GitHub repository.
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Open a Pull Request
License
MIT
| 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 was computed. 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 was computed. 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. |
-
net8.0
NuGet packages (1)
Showing the top 1 NuGet packages that depend on SAValidation.Common:
| Package | Downloads |
|---|---|
|
SAValidation.PhoneNumbers
South African phone number validation library |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.4 | 100 | 3/12/2026 |