Skip to content

Latest commit

 

History

History
347 lines (307 loc) · 11.9 KB

File metadata and controls

347 lines (307 loc) · 11.9 KB

System.ComponentModel.DataAnnotations


IPAddressAttribute

Validates that a property, field, or parameter contains a valid IP address. Supports both IPv4 and IPv6 address formats.

public class IPAddressAttribute : ValidationAttribute

Static Methods

TryIsValid

bool TryIsValid(string value, out string errorMessage)

Summary: Attempts to validate the specified string as an IP address using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid IP address; otherwise, false.

TryIsValid

bool TryIsValid(string value, IPAddressAttribute attribute, out string errorMessage)

Summary: Attempts to validate the specified string as an IP address using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid IP address; otherwise, false.

Properties

Required

Required

Summary: Gets or sets a value indicating whether the IP address value is required.

Methods

IsValid

bool IsValid(object value)

IsoCurrencySymbolAttribute

Validates that a property, field, or parameter contains a valid ISO 4217 currency code. The value must be a three-character uppercase string (e.g., USD, EUR, GBP). Optionally validates against a specific set of allowed currency codes.

public class IsoCurrencySymbolAttribute : ValidationAttribute

Properties

IsoCurrencySymbols

IsoCurrencySymbols

Summary: Gets or sets an optional array of specific ISO currency codes that are allowed. If empty, all valid ISO currency codes from available cultures are accepted.

Required

Required

Summary: Gets or sets a value indicating whether the currency code value is required.

Methods

IsValid

bool IsValid(object value)

KeyStringAttribute

Validates that a property or field contains a valid key string. By default, excludes spaces, periods, at signs, and apostrophes, and disallows strings starting with underscores. This attribute extends System.ComponentModel.DataAnnotations.StringAttribute with key-specific validation rules.

public class KeyStringAttribute : StringAttribute

Static Methods

TryIsValid

bool TryIsValid(string value, out string errorMessage)

Summary: Attempts to validate the specified string as a key string using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid key string; otherwise, false.

TryIsValid

bool TryIsValid(string value, KeyStringAttribute attribute, out string errorMessage)

Summary: Attempts to validate the specified string as a key string using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid key string; otherwise, false.


RegularExpressionAttributeExtensions

Extension methods for System.ComponentModel.DataAnnotations.RegularExpressionAttribute.

public static class RegularExpressionAttributeExtensions

Static Methods

GetEscapedPattern

string GetEscapedPattern(this RegularExpressionAttribute regularExpressionAttribute, bool ensureQuotes = True)

Summary: Gets the escaped pattern from a System.ComponentModel.DataAnnotations.RegularExpressionAttribute suitable for code generation.

Parameters:
     regularExpressionAttribute  -  The regular expression attribute.
     ensureQuotes  -  If set to , ensures the result is wrapped in double quotes.

Returns: The escaped pattern string.


StringAttribute

Validates that a property, field, or parameter contains a string value meeting specified constraints. Supports validation of length, invalid characters, invalid prefixes, and regular expression patterns.

public class StringAttribute : ValidationAttribute

Static Methods

TryIsValid

bool TryIsValid(string value, out string errorMessage)

Summary: Attempts to validate the specified string using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is valid; otherwise, false.

TryIsValid

bool TryIsValid(string value, StringAttribute attribute, out string errorMessage)

Summary: Attempts to validate the specified string using default validation settings.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is valid; otherwise, false.

Properties

InvalidCharacters

InvalidCharacters

Summary: Gets or sets an array of characters that are not allowed in the string.

InvalidPrefixStrings

InvalidPrefixStrings

Summary: Gets or sets an array of prefixes that the string cannot start with.

MaxLength

MaxLength

Summary: Gets or sets the maximum allowed length of the string.

MinLength

MinLength

Summary: Gets or sets the minimum allowed length of the string.

RegularExpression

RegularExpression

Summary: Gets or sets a regular expression pattern that the string must match. If set, the string will be validated against this pattern with a 2-second timeout.

Required

Required

Summary: Gets or sets a value indicating whether the string value is required.

Methods

IsValid

bool IsValid(object value)

UriAttribute

Validates that a property, field, or parameter contains a valid URI with an allowed scheme. Supports HTTP, HTTPS, FTP, FTPS, File, and OPC TCP schemes.

public class UriAttribute : ValidationAttribute

Static Fields

Default

UriAttribute Default

Summary: A default configuration that allows all URI schemes and does not require a value.

HttpOrHttps

UriAttribute HttpOrHttps

Summary: A preset configuration that only allows HTTP and HTTPS schemes and requires a value.

OpcTcp

UriAttribute OpcTcp

Summary: A preset configuration that only allows OPC TCP scheme (opc.tcp://) URIs and requires a value.

Static Methods

IsValidHttpOrHttps

bool IsValidHttpOrHttps(object value)

Summary: Validates whether the specified value is a valid HTTP or HTTPS URI.

Parameters:
     value  -  The value to validate.

Returns: true if the value is a valid http:// or https:// URI; otherwise, false.

IsValidOpcTcp

bool IsValidOpcTcp(object value)

Summary: Validates whether the specified value is a valid OPC TCP URI.

Parameters:
     value  -  The value to validate.

Returns: true if the value is a valid opc.tcp:// URI; otherwise, false.

TryIsValid

bool TryIsValid(string value, out string errorMessage)

Summary: Attempts to validate the specified string as a URI using default validation settings (all schemes allowed).

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid URI; otherwise, false.

TryIsValid

bool TryIsValid(string value, UriAttribute attribute, out string errorMessage)

Summary: Attempts to validate the specified string as a URI using default validation settings (all schemes allowed).

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid URI; otherwise, false.

TryIsValidHttpOrHttps

bool TryIsValidHttpOrHttps(string value, out string errorMessage)

Summary: Attempts to validate the specified string as an HTTP or HTTPS URI.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid http:// or https:// URI; otherwise, false.

TryIsValidOpcTcp

bool TryIsValidOpcTcp(string value, out string errorMessage)

Summary: Attempts to validate the specified string as an OPC TCP URI.

Parameters:
     value  -  The string value to validate.
     errorMessage  -  When validation fails, contains a message describing the validation error.

Returns: true if the value is a valid opc.tcp:// URI; otherwise, false.

Properties

AllowFile

AllowFile

Summary: Gets or sets a value indicating whether the File scheme is allowed.

AllowFtp

AllowFtp

Summary: Gets or sets a value indicating whether the FTP scheme is allowed.

AllowFtps

AllowFtps

Summary: Gets or sets a value indicating whether the FTPS scheme is allowed.

AllowHttp

AllowHttp

Summary: Gets or sets a value indicating whether the HTTP scheme is allowed.

AllowHttps

AllowHttps

Summary: Gets or sets a value indicating whether the HTTPS scheme is allowed.

AllowOpcTcp

AllowOpcTcp

Summary: Gets or sets a value indicating whether the OPC TCP scheme is allowed.

Required

Required

Summary: Gets or sets a value indicating whether the URI value is required.

Methods

IsValid

bool IsValid(object value)

Generated by MarkdownCodeDoc version 1.2