Class Validator
Contains validation methods
Inheritance
Inherited Members
Namespace: EPiServer.Framework
Assembly: EPiServer.Framework.dll
Version: 11.20.7Syntax
public static class Validator
Fields
DefaultEmailRegexString
The default string used for validation of email adresses.
Declaration
public const string DefaultEmailRegexString = "^[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$"
Field Value
Type | Description |
---|---|
System.String |
Remarks
The difference between this and EmailRegexString is that the later can be changed during the lifetime of the application.
DefaultMultipleEmailRegexString
The default string used for validation of multiple email adresseses.
Declaration
public const string DefaultMultipleEmailRegexString = "^([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?[,][\\040]?)*([a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9]))$"
Field Value
Type | Description |
---|---|
System.String |
Remarks
The difference between this and MultipleEmailRegexString is that the later can be changed during the lifetime of the application.
Properties
EmailRegex
Gets the email regex that is used for EPiServer products.
Declaration
public static Regex EmailRegex { get; }
Property Value
Type | Description |
---|---|
System.Text.RegularExpressions.Regex | The email regex that is used for EPiServer products. |
Remarks
If you want to change the regular expression used then set the EmailRegexString to your own regex.
EmailRegexString
Gets or sets the email regex string that is used validating email addresses in EPiServer products.
Declaration
public static string EmailRegexString { get; set; }
Property Value
Type | Description |
---|---|
System.String | The email regex string that is used validating email addresses in EPiServer products. |
Remarks
Note that the regex should handle casing since case sensivity is not supported by the RegularExpressionValidator control.
MultipleEmailRegex
Gets the regular expression for multiple email addresses that is used for EPiServer products.
Declaration
public static Regex MultipleEmailRegex { get; }
Property Value
Type | Description |
---|---|
System.Text.RegularExpressions.Regex | The email regex that is used to validate multiple email addresses for EPiServer products. |
Remarks
If you want to change the regular expression used then set the MultipleEmailRegexString to your own regex.
MultipleEmailRegexString
Gets or sets the email regex string that is used validating multiple email addresses in EPiServer products.
Declaration
public static string MultipleEmailRegexString { get; set; }
Property Value
Type | Description |
---|---|
System.String | The email regex string that is used validating multiple email addresses in EPiServer products. |
Remarks
Note that the regex should handle casing since case sensivity is not supported by the RegularExpressionValidator control.
Methods
ThrowIfContainsSqlInjectionChars(String, String)
Throws an System.ArgumentException if
Declaration
public static void ThrowIfContainsSqlInjectionChars(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the argument |
System.String | value | The value to check |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | Thrown if the value contains potential SQL injection code |
ThrowIfInvalidLength(String, String, Int32, Int32)
Throws an System.ArgumentException if
Declaration
public static void ThrowIfInvalidLength(string name, string value, int minLength, int maxLength)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the argument |
System.String | value | The value to check |
System.Int32 | minLength | The minimum length the string can be |
System.Int32 | maxLength | The maximum length the string can be |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the value to check is null or empty string |
System.ArgumentException | If the length requirements are not met |
ThrowIfInvalidSqlIdentifier(IEnumerable<String>)
Declaration
public static void ThrowIfInvalidSqlIdentifier(IEnumerable<string> identifiers)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | identifiers |
ThrowIfNull(String, Object)
Throws an System.ArgumentNullException if
Declaration
public static void ThrowIfNull(string name, object value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the argument |
System.Object | value | The value to check |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the value to check is null |
ThrowIfNullOrEmpty(String, String)
Throws an System.ArgumentNullException if
Declaration
public static void ThrowIfNullOrEmpty(string name, string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the argument |
System.String | value | The value to check |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown if the value to check is null or empty string |