Skip to content

nkelemen18/NKelemen18.HtmlColors

Repository files navigation

HTML Color validator library for .NET 7

Installation

This package is available on NuGet: NKelemen18.HtmlColors

nuget install NKelemen18.HtmlColors

Description

ℹ️ This project is a port of Validate Color 🌈 by Wallace Sidhrée.

Currently support RGB, RGBA, HEX and 140 HtmlColors

Usage

using NKelemen18.HtmlColors;

// Test RGB colors
Console.WriteLine(HtmlColorValidator.IsRgbHtmlColor("rgb(10)")); // False
Console.WriteLine(HtmlColorValidator.IsRgbOrRgbaHtmlColor("rgba(255, 255, 255)")); // True

// Test Hex colors
Console.WriteLine(HtmlColorValidator.IsHexHtmlColor("#invalid")); // False
Console.WriteLine(HtmlColorValidator.IsHexHtmlColor("#89326f")); // True

// Test HTML color names
Console.WriteLine(HtmlColorValidator.IsBaseHtmlColorName("unknown-pink")); // False
Console.WriteLine(HtmlColorValidator.IsBaseHtmlColorName("darkred")); // True

// Test special HTML color names
Console.WriteLine(HtmlColorValidator.IsSpecialHtmlColorName(HtmlColors.Transparent)); //True
Console.WriteLine(HtmlColorValidator.IsSpecialHtmlColorName("transparent")); // True
Console.WriteLine(HtmlColorValidator.IsSpecialHtmlColorName("unset")); // False
Console.WriteLine(HtmlColorValidator.IsSpecialHtmlColorName("inherit")); // True
Console.WriteLine(HtmlColorValidator.IsSpecialHtmlColorName("darkred")); // False

©️ Norbert Kelemen

Icon by Freepik

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages