I'm developing in Asp.NET MVC Core
and I need to use DataType
to CNPJ
, I saw that it has DataType.Custom
, but I could not understand how to use it.
[Display(Name = "CNPJ")]
[DataType(DataType.Custom)]
[RegularExpression(@"^\d{2}.?\d{3}.?\d{3}/?\d{4}-?\d{2}$",
ErrorMessage = "{0} deve ter 8 digitos e apenas numero")]
[Required(ErrorMessage = "{0} é Obrigatorio")]
public string Cnpj { get; set; }