RegularExpressionAttribute(String) Construtor

Definição

Inicializa uma nova instância da classe RegularExpressionAttribute.Initializes a new instance of the RegularExpressionAttribute class.

public:
 RegularExpressionAttribute(System::String ^ pattern);
public RegularExpressionAttribute (string pattern);
new System.ComponentModel.DataAnnotations.RegularExpressionAttribute : string -> System.ComponentModel.DataAnnotations.RegularExpressionAttribute
Public Sub New (pattern As String)

Parâmetros

pattern
String

A expressão regular que é usada para validar o valor do campo de dados.The regular expression that is used to validate the data field value.

Exceções

pattern é null.pattern is null.

Exemplos

O exemplo a seguir mostra como aplicar o RegularExpressionAttribute a um campo de dados.The following example shows how to apply the RegularExpressionAttribute to a data field. Se a validação falhar, o código no exemplo exibirá a mensagem de erro de validação fornecida pelo Dados Dinâmicos.If validation fails, the code in the example displays the validation error message that is provided by Dynamic Data.

// Allow up to 40 uppercase and lowercase 
// characters. Use standard error.
[RegularExpression(@"^[a-zA-Z''-'\s]{1,40}$")]
public object LastName;
' Allow up to 40 uppercase and lowercase 
' characters. Use standard error.
<RegularExpression("^[a-zA-Z''-'\s]{1,40}$")> _
Public LastName As Object

Aplica-se a