CaseON 1.3.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package CaseON --version 1.3.0                
NuGet\Install-Package CaseON -Version 1.3.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="CaseON" Version="1.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CaseON --version 1.3.0                
#r "nuget: CaseON, 1.3.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.
// Install CaseON as a Cake Addin
#addin nuget:?package=CaseON&version=1.3.0

// Install CaseON as a Cake Tool
#tool nuget:?package=CaseON&version=1.3.0                

CaseON: A Comprehensive C# String Manipulation and Validation Library

CaseON is a lightweight and efficient C# library designed to simplify string manipulation and validation. It provides robust utilities for converting strings to various casing styles, validating common data formats, and, with the addition of the MatchON namespace, enables advanced string similarity comparisons.

Features

String Casing Styles:

Convert strings into the following popular casing formats:

  • snake_case
  • kebab-case
  • PascalCase
  • camelCase
  • Sentence case
  • Title Case

String Validation Methods:

Extensive helper methods to validate common string formats:

  • Email Validation: Validates if the string is a valid email address.
  • URL Validation: Validates if the string is a properly formatted URL.
  • IP Address Validation (IPv4 & IPv6): Validates if the string matches the format for valid IPv4 and IPv6 addresses.
  • Alphanumeric, Numeric, Alphabetic Validation: Verifies if the string contains only alphanumeric, numeric, or alphabetic characters.
  • Phone Number Validation: Ensures the 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: Validates if the string is a valid Base64 encoded string.
  • 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: Verifies if the string is a valid date, postal code (supports multiple countries), or physical address.
  • JSON and XML Validation: Validates if the string is in proper JSON or XML format.

Advanced String Similarity Matching:

With the new MatchON namespace, CaseON adds several advanced string similarity algorithms:

  • Levenshtein Distance: Measures the minimum number of single-character edits required to transform one string into another.
  • Jaro-Winkler Similarity: Computes the similarity between two strings, focusing on the number of common characters and their order.
  • Longest Common Subsequence (LCS): Measures similarity based on the longest subsequence present in both strings.

Robust Input Handling:

  • Throws informative ArgumentExceptions 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.3.0 Changelog

New Features:

  • New MatchON Namespace:

    • Introduced a new namespace MatchON that includes advanced string similarity matching algorithms to compare strings with greater accuracy. The following methods are now available:
      • Levenshtein Distance: Measures the number of edits required to transform one string into another, with a normalized similarity score returned between 0 and 1.
      • Jaro-Winkler Similarity: Computes the similarity based on the number of common characters and their relative order, returning a score adjusted for prefixes.
      • Longest Common Subsequence (LCS): Computes the longest subsequence common to both strings and provides a similarity score based on the LCS length.
  • String Validation Methods:

    • Enhanced the string validation capabilities with 15+ new validation methods for various formats including email, URL, IP addresses, phone numbers, and more.

Bug Fixes & Improvements:

  • Fixed minor bugs related to input handling for edge cases in validation methods.
  • Improved the performance of string casing conversion methods for longer strings.

Usage

  1. Installation: You can easily add CaseON to your project via NuGet. Alternatively, you can directly include the source code in your project.

  2. 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}");


// String Similarity Matching with MatchON
string string1 = "hello world";
string string2 = "hello wrld";

double levenshteinSimilarity = MatchON.GetSimilarity(string1, string2);  // Similarity based on Levenshtein Distance
double jaroWinklerSimilarity = MatchON.GetJaroWinklerSimilarity(string1, string2); // Similarity based on Jaro-Winkler
double lcsSimilarity = MatchON.GetLcsSimilarity(string1, string2);  // Similarity based on Longest Common Subsequence

Console.WriteLine($"Levenshtein Similarity: {levenshteinSimilarity}");  // Output: Similarity score between 0 and 1
Console.WriteLine($"Jaro-Winkler Similarity: {jaroWinklerSimilarity}");  // Output: Similarity score between 0 and 1
Console.WriteLine($"LCS Similarity: {lcsSimilarity}");  // Output: Similarity score between 0 and 1
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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

Release Notes for ValidateON 1.3.0

This release introduces MatchON, a new class added to the ValidateON library, enhancing its data validation capabilities. Version 1.3.0 continues to build on the previous success of the library, providing even more powerful features for developers working with data validation.

In addition to the existing validation methods for common data types like email addresses, URLs, phone numbers, and credit card numbers, MatchON brings in powerful pattern matching functionalities. This new class introduces methods for validating regular expressions (regex) and custom patterns to match complex input strings, further expanding the library's versatility in handling a wide variety of data formats.

Version 1.3.0 also includes the previously introduced improvements from version 1.2.0, which added support for validating advanced data formats such as GUIDs, MAC addresses, IBANs, JSON, XML, and Bitcoin wallet addresses. These methods ensure that developers can easily validate a broad range of data with simple and efficient APIs.

With MatchON in version 1.3.0, developers now have a comprehensive solution for both basic and advanced data validation tasks, including the ability to match strings against custom patterns and regular expressions, alongside the existing validation methods. This update provides even greater flexibility, ensuring that data validation needs can be met in diverse scenarios.

We encourage users to try ValidateON 1.3.0, integrate it into their projects, and provide feedback for future enhancements.