CaseON 1.2.0
See the version list below for details.
dotnet add package CaseON --version 1.2.0
NuGet\Install-Package CaseON -Version 1.2.0
<PackageReference Include="CaseON" Version="1.2.0" />
paket add CaseON --version 1.2.0
#r "nuget: CaseON, 1.2.0"
// Install CaseON as a Cake Addin #addin nuget:?package=CaseON&version=1.2.0 // Install CaseON as a Cake Tool #tool nuget:?package=CaseON&version=1.2.0
CaseON: A C# String Casing and Validation Library
CaseON is a lightweight C# library providing a simple and efficient way to convert strings to various casing styles and validate common data formats. It handles different separators, offers robust error handling, and includes a wide range of validation utilities.
Features
String Casing Styles:
Supports conversion to the following casing styles:
snake_case
kebab-case
PascalCase
camelCase
Sentence case
Title Case
String Validation Methods:
A collection of helper methods to validate common string formats:
- Email Validation: Checks if a string is a valid email address.
- URL Validation: Validates if a string is a properly formatted URL.
- IP Address Validation (IPv4 & IPv6): Ensures a string matches the format for valid IPv4 and IPv6 addresses.
- Alphanumeric, Numeric, Alphabetic Validation: Verifies if a string contains only alphanumeric, numeric, or alphabetic characters.
- Phone Number Validation: Ensures a string matches the format of a valid phone number.
- GUID, File Path, and Hex Color Validation: Validates GUIDs, file paths, and hex color codes.
- Base64 String Validation: Verifies if a string is in valid Base64 format.
- Credit Card, Routing Number, and CVV Validation: Validates credit card numbers, bank routing numbers, and CVVs using standard algorithms.
- IBAN, ISBN, and Social Security Number (SSN) Validation: Validates international banking account numbers, ISBNs, and US SSNs.
- Date, Postal Code, and Address Validation: Checks if a string is a valid date, postal code (supporting multiple countries), or physical address.
- JSON and XML Validation: Verifies if a string is a valid JSON or XML formatted string.
Robust Input Handling:
- Throws informative
ArgumentException
s for null or empty/whitespace input strings. - Handles strings containing spaces, underscores, hyphens, and various separators.
- Ensures that common data formats are properly validated before usage.
Easy to Use:
- Simple static methods provide a clean and intuitive API.
- Built-in validation methods for common use cases make it easy to ensure input correctness.
Lightweight:
- Minimal dependencies, easy to integrate into existing projects.
- The library can be used for both string casing conversions and data format validation.
Version 1.2.0 Changelog
New Features:
- String Validation Methods: Added 15+ string validation methods to validate common formats like email, URLs, IP addresses, credit card numbers, postal codes, dates, and more.
- IsValidEmail: Validates if the string is a valid email address.
- IsValidUrl: Validates if the string is a valid URL.
- IsValidIPv4 & IsValidIPv6: Validates if the string is a valid IPv4 or IPv6 address.
- IsAlphanumeric: Checks if the string contains only alphanumeric characters.
- IsValidPhoneNumber: Validates if the string matches a valid phone number format.
- IsBase64String: Validates if the string is in valid Base64 format.
- IsValidCreditCard: Validates if the string is a valid credit card number using Luhn's algorithm.
- IsValidRoutingNumber: Validates a US bank routing number using checksum.
- IsValidIban: Validates an International Bank Account Number (IBAN) using modulus-97 check.
- IsValidIsbn: Validates an ISBN (10 or 13 digits) using checksum verification.
- IsValidDate: Validates if the string is a valid date in a specified format.
- IsValidPostalCode: Validates postal codes for different countries (US, UK, CA, DE, etc.).
- IsValidAddress: Validates a physical address format.
- IsValidJson & IsValidXml: Validates if the string is a valid JSON or XML format.
Usage
Installation: You can easily add CaseON to your project via NuGet. Alternatively, you can directly include the source code in your project.
Basic Example:
using CaseON;
// String Casing
string myString = "This Is A Test String";
string snakeCase = CaseON.ConvertON.ToSnakeCase(myString); // Output: this_is_a_test_string
string kebabCase = CaseON.ConvertON.ToKebabCase(myString); // Output: this-is-a-test-string
string pascalCase = CaseON.ConvertON.ToPascalCase(myString); // Output: ThisIsATestString
string camelCase = CaseON.ConvertON.ToCamelCase(myString); // Output: thisIsATestString
string sentenceCase = CaseON.ConvertON.ToSentenceCase(myString); // Output: This is a test string
string titleCase = CaseON.ConvertON.ToTitleCase(myString); // Output: This Is A Test String
Console.WriteLine($"Snake Case: {snakeCase}");
Console.WriteLine($"Kebab Case: {kebabCase}");
Console.WriteLine($"Pascal Case: {pascalCase}");
Console.WriteLine($"Camel Case: {camelCase}");
Console.WriteLine($"Sentence Case: {sentenceCase}");
Console.WriteLine($"Title Case: {titleCase}");
string email = "test@example.com";
string url = "https://www.example.com";
string ipAddress = "192.168.1.1";
string phoneNumber = "+1234567890";
string postalCode = "90210";
string date = "2024-11-26";
bool isValidEmail = CaseON.ValidateON.IsValidEmail(email); // Output: true
bool isValidUrl = CaseON.ValidateON.IsValidUrl(url); // Output: true
bool isValidIp = CaseON.ValidateON.IsValidIPv4(ipAddress); // Output: true
bool isValidPhone = CaseON.ValidateON.IsValidPhoneNumber(phoneNumber); // Output: true
bool isValidPostal = CaseON.ValidateON.IsValidPostalCode(postalCode); // Output: true
bool isValidDate = CaseON.ValidateON.IsValidDate(date); // Output: true
Console.WriteLine($"Valid Email: {isValidEmail}");
Console.WriteLine($"Valid URL: {isValidUrl}");
Console.WriteLine($"Valid IP Address: {isValidIp}");
Console.WriteLine($"Valid Phone Number: {isValidPhone}");
Console.WriteLine($"Valid Postal Code: {isValidPostal}");
Console.WriteLine($"Valid Date: {isValidDate}");
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
-
net6.0
- No dependencies.
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.3.1-beta | 27 | 11/27/2024 |
1.3.0 | 26 | 11/27/2024 |
1.2.0 | 62 | 11/26/2024 |
1.1.0 | 68 | 11/21/2024 |
This release introduces ValidateON version 1.2.0, a comprehensive C# library for data validation. Building on the success of earlier versions, ValidateON now includes a wide range of input validation methods to ensure data integrity and consistency. It provides simple and efficient APIs to validate common data types such as email addresses, URLs, IP addresses, phone numbers, credit card numbers, postal codes, and more.
Version 1.2.0 expands the library’s capabilities by adding support for validating complex data formats like GUIDs, MAC addresses, IBANs, JSON, XML, and even Bitcoin wallet addresses. The library ensures robust error handling, throwing informative exceptions when invalid inputs are detected. Its minimal dependencies make it easy to integrate into any .NET project, and its static methods offer a straightforward approach to validating various forms of data.
This release builds on the foundation set by the initial version and introduces new methods for advanced data validation, offering greater flexibility and functionality. Future versions may include even more validation types and enhancements based on user feedback.
We encourage users to try ValidateON 1.2.0, integrate it into their projects, and provide feedback for future improvements.