Class ValidationsStringExtensions
Provides extension methods for string operations, enhancing the built-in string manipulation capabilities.
Inherited Members
Namespace: Coree.NETStandard.Extensions.Validations.String
Assembly: Coree.NETStandard.dll
Syntax
public static class ValidationsStringExtensions
Methods
| Edit this page View SourceIsValidJson(string)
Validates whether the specified string is valid JSON.
Declaration
public static bool IsValidJson(this string jsonString)
Parameters
Type | Name | Description |
---|---|---|
string | jsonString | The JSON string to validate. |
Returns
Type | Description |
---|---|
bool | true if the string is valid JSON; otherwise, false. |
IsValidXml(string)
Validates whether the specified string is well-formed XML.
Declaration
public static bool IsValidXml(this string xmlString)
Parameters
Type | Name | Description |
---|---|---|
string | xmlString | The XML string to validate. |
Returns
Type | Description |
---|---|
bool | true if the string is a well-formed XML; otherwise, false. |
ValidateWhitelistBlacklist(string, List<string>?, List<string>?)
Extension method to evaluate this string instance against optional whitelist and blacklist patterns to determine whether the operation should continue.
Declaration
public static bool ValidateWhitelistBlacklist(this string input, List<string>? whitelist = null, List<string>? blacklist = null)
Parameters
Type | Name | Description |
---|---|---|
string | input | The string instance to be evaluated. |
List<string> | whitelist | An optional list of whitelist patterns. If the string matches any of these patterns, the method immediately returns true, indicating that the operation should continue. |
List<string> | blacklist | An optional list of blacklist patterns. If the string matches any of these patterns, the method returns false, indicating that the operation should be halted. |
Returns
Type | Description |
---|---|
bool | True if the operation should continue (either by passing a whitelist check or not failing a blacklist check), or false if the string matches a blacklist pattern and should be halted. |
ValidateWhitelistBlacklist(string, string[]?, string[]?)
Extension method to evaluate this string instance against optional whitelist and blacklist patterns to determine whether the operation should continue.
Declaration
public static bool ValidateWhitelistBlacklist(this string input, string[]? whitelist = null, string[]? blacklist = null)
Parameters
Type | Name | Description |
---|---|---|
string | input | The string instance to be evaluated. |
string[] | whitelist | An optional list of whitelist patterns. If the string matches any of these patterns, the method immediately returns true, indicating that the operation should continue. |
string[] | blacklist | An optional list of blacklist patterns. If the string matches any of these patterns, the method returns false, indicating that the operation should be halted. |
Returns
Type | Description |
---|---|
bool | True if the operation should continue (either by passing a whitelist check or not failing a blacklist check), or false if the string matches a blacklist pattern and should be halted. |