Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
237 lines (224 sloc) 15.1 KB
<Type Name="RegularExpressionAttribute" FullName="System.ComponentModel.DataAnnotations.RegularExpressionAttribute">
<TypeSignature Language="C#" Value="public class RegularExpressionAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit RegularExpressionAttribute extends System.ComponentModel.DataAnnotations.ValidationAttribute" />
<TypeSignature Language="DocId" Value="T:System.ComponentModel.DataAnnotations.RegularExpressionAttribute" />
<TypeSignature Language="VB.NET" Value="Public Class RegularExpressionAttribute&#xA;Inherits ValidationAttribute" />
<TypeSignature Language="C++ CLI" Value="public ref class RegularExpressionAttribute : System::ComponentModel::DataAnnotations::ValidationAttribute" />
<TypeSignature Language="F#" Value="type RegularExpressionAttribute = class&#xA; inherit ValidationAttribute" />
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.ComponentModel.DataAnnotations.ValidationAttribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute FrameworkAlternate="netcore-2.0;netcore-2.1;netcore-2.2;dotnet-uwp-10.0">
<AttributeName>System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-3.5">
<AttributeName>System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field, AllowMultiple=false)</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="xamarinandroid-7.1;xamarinios-10.8;netcore-1.0;netcore-1.1;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;xamarinmac-3.0;netcore-3.0">
<AttributeName>System.AttributeUsage(System.AttributeTargets.Property | System.AttributeTargets.Field | System.AttributeTargets.Parameter, AllowMultiple=false)</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Specifies that a data field value in ASP.NET Dynamic Data must match the specified regular expression.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You apply the RegularExpressionAttribute attribute to a property when you need to validate values for the property against a regular expression. The regular expression enables you to specify very precisely the format of valid values. The Pattern property contains the regular expression.If the value of the property is null or an empty string (""), the value automatically passes validation for the RegularExpressionAttribute attribute. To validate that the value is not `null` or an empty string, use the **RequiredAttribute** attribute.
## Examples
The following example shows how to use the <xref:System.ComponentModel.DataAnnotations.RegularExpressionAttribute> attribute to validate the FirstName and LastName data fields. The regular expression allows up to 40 uppercase and lowercase characters. The example performs the following tasks:
- Implements a metadata partial class and the associated metadata class.
- In the associated metadata class, applies the <xref:System.ComponentModel.DataAnnotations.RegularExpressionAttribute> attribute to the FirstName and LastName data fields, specifying the pattern and custom error messages.
[!code-csharp[System.ComponentModel.DataAnnotations.RegularExpressionAttribute#1](~/samples/snippets/csharp/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.RegularExpressionAttribute/CS/Customer.cs#1)]
[!code-vb[System.ComponentModel.DataAnnotations.RegularExpressionAttribute#1](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.RegularExpressionAttribute/VB/Customer.vb#1)]
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public RegularExpressionAttribute (string pattern);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string pattern) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.#ctor(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (pattern As String)" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; RegularExpressionAttribute(System::String ^ pattern);" />
<MemberSignature Language="F#" Value="new System.ComponentModel.DataAnnotations.RegularExpressionAttribute : string -&gt; System.ComponentModel.DataAnnotations.RegularExpressionAttribute" Usage="new System.ComponentModel.DataAnnotations.RegularExpressionAttribute pattern" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="pattern" Type="System.String" />
</Parameters>
<Docs>
<param name="pattern">The regular expression that is used to validate the data field value.</param>
<summary>Initializes a new instance of the <see cref="T:System.ComponentModel.DataAnnotations.RegularExpressionAttribute" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Examples
The following example shows how to apply the <xref:System.ComponentModel.DataAnnotations.RegularExpressionAttribute> to a data field. If validation fails, the code in the example displays the validation error message that is provided by Dynamic Data.
[!code-csharp[System.ComponentModel.DataAnnotations.RegularExpressionAttribute#2](~/samples/snippets/csharp/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.RegularExpressionAttribute/CS/Customer.cs#2)]
[!code-vb[System.ComponentModel.DataAnnotations.RegularExpressionAttribute#2](~/samples/snippets/visualbasic/VS_Snippets_WebNet/System.ComponentModel.DataAnnotations.RegularExpressionAttribute/VB/Customer.vb#2)]
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="pattern" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="FormatErrorMessage">
<MemberSignature Language="C#" Value="public override string FormatErrorMessage (string name);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance string FormatErrorMessage(string name) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.FormatErrorMessage(System.String)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function FormatErrorMessage (name As String) As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override System::String ^ FormatErrorMessage(System::String ^ name);" />
<MemberSignature Language="F#" Value="override this.FormatErrorMessage : string -&gt; string" Usage="regularExpressionAttribute.FormatErrorMessage name" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
</Parameters>
<Docs>
<param name="name">The name of the field that caused the validation failure.</param>
<summary>Formats the error message to display if the regular expression validation fails.</summary>
<returns>The formatted error message.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.FormatErrorMessage%2A> creates the error message by using the name of the data field that caused the validation failure. You can override this method in custom validation attributes to customize how errors are created or to provide a more complex message that contains parameters that you evaluate at run time.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="IsValid">
<MemberSignature Language="C#" Value="public override bool IsValid (object value);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool IsValid(object value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.IsValid(System.Object)" />
<MemberSignature Language="VB.NET" Value="Public Overrides Function IsValid (value As Object) As Boolean" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; override bool IsValid(System::Object ^ value);" />
<MemberSignature Language="F#" Value="override this.IsValid : obj -&gt; bool" Usage="regularExpressionAttribute.IsValid value" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="value" Type="System.Object" />
</Parameters>
<Docs>
<param name="value">The data field value to validate.</param>
<summary>Checks whether the value entered by the user matches the regular expression pattern.</summary>
<returns>
<see langword="true" /> if validation is successful; otherwise, <see langword="false" />.</returns>
<remarks>To be added.</remarks>
<exception cref="T:System.ComponentModel.DataAnnotations.ValidationException">The data field value did not match the regular expression pattern.</exception>
</Docs>
</Member>
<Member MemberName="MatchTimeoutInMilliseconds">
<MemberSignature Language="C#" Value="public int MatchTimeoutInMilliseconds { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance int32 MatchTimeoutInMilliseconds" />
<MemberSignature Language="DocId" Value="P:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.MatchTimeoutInMilliseconds" />
<MemberSignature Language="VB.NET" Value="Public Property MatchTimeoutInMilliseconds As Integer" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property int MatchTimeoutInMilliseconds { int get(); void set(int value); };" />
<MemberSignature Language="F#" Value="member this.MatchTimeoutInMilliseconds : int with get, set" Usage="System.ComponentModel.DataAnnotations.RegularExpressionAttribute.MatchTimeoutInMilliseconds" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets the amount of time in milliseconds to execute a single matching operation before the operation times out.</summary>
<value>The amount of time in milliseconds to execute a single matching operation.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Pattern">
<MemberSignature Language="C#" Value="public string Pattern { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance string Pattern" />
<MemberSignature Language="DocId" Value="P:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.Pattern" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property Pattern As String" />
<MemberSignature Language="C++ CLI" Value="public:&#xA; property System::String ^ Pattern { System::String ^ get(); };" />
<MemberSignature Language="F#" Value="member this.Pattern : string" Usage="System.ComponentModel.DataAnnotations.RegularExpressionAttribute.Pattern" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.Annotations</AssemblyName>
<AssemblyVersion>4.0.10.0</AssemblyVersion>
<AssemblyVersion>4.1.0.0</AssemblyVersion>
<AssemblyVersion>4.2.0.0</AssemblyVersion>
</AssemblyInfo>
<AssemblyInfo>
<AssemblyName>System.ComponentModel.DataAnnotations</AssemblyName>
<AssemblyVersion>2.0.5.0</AssemblyVersion>
<AssemblyVersion>3.5.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName>get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.String</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the regular expression pattern.</summary>
<value>The pattern to match.</value>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
You can’t perform that action at this time.