Questions tagged as 'dataannotations'

1
answer

DataAnnotation: How to validate "e-mail" property, check whether or not it exists in the database, with attribute not being in the client but in the Server

I have a layered application, and in my presentation layer, I have a ViewModel that is UsuarioViewModel within this I have a property call public email {get; set;} . > that is being registered already exists in...
asked by 05.01.2015 / 21:39
1
answer

One of the fields must be mandatory - DataAnnotation [duplicate]

Code sample: Model: [Required(ErrorMessage = "Campo CPF ou CNPJ obrigatório")] [Display(Name = "CPF")] public string CPF { get; set; } [Display(Name = "CNPJ")] public string CNPJ { get; set; } User must fill in one of the CPF or CNP...
asked by 24.04.2017 / 22:04
1
answer

how to create index order desc through DataAnnotations

I need to create an index in my model, however I need it to be decreasing How do I do: [Index("Ix_PrecoConsultData", IsUnique = false, Order = 1)] public DateTime DataCadastro { get; set; } It creates the index but with ASC order it need...
asked by 11.01.2017 / 21:07
1
answer

Validating form data in ASP.NET MVC

Is there any quicker and simpler way to validate a form's data in ASP.NET? so I do not have to be doing as many treatments as in the example below: [HttpPost] public ActionResult Attempt(string email, string password, Entities db) { ViewBa...
asked by 02.03.2016 / 22:30
2
answers

Template, relationship with DataAnnotations

If I have a Customers entity public class Cliente { public int ClienteId { get; set; } public string Email { get; set; } public string Nome { get; set; } } If I create a Boleto entity public class Boleto {...
asked by 03.02.2016 / 16:07
1
answer

custom rangeValidation

How to make a range validator where Max is the current year + 1? I'm trying to do a dataannotation validation on my models I want to make a range validation from 1950 until current year +1 By default it is not possible to do this using the...
asked by 25.08.2017 / 15:07
1
answer

Validating form with DataAnnotations in MVC

I'm trying to validate forms using DataAnnotation, I tried directly on model or my viewmodel and none of them works. View Model: public class CieloViewModelTransacaoPartial { [Required(ErrorMessage = "Token é obrigatório")...
asked by 02.05.2016 / 16:57
1
answer

Fluent API zero-to-one Relationship 0-1 - bringing results from another relationship

I'm trying to make the relationship between my Cliente and CieloToken , tried with Fluent API and Data Annotation , I mixed them both and it did not work. In fact it does, but even though Cliente does not have...
asked by 12.05.2016 / 20:46
1
answer

Validation DataAnnotation displaying message in English

Good afternoon, In my system I made the validations with data annotations, locally the messages are displayed in Portuguese, when I publish in the hosting server the text message is displayed in English, someone knows how do I keep in Portugu...
asked by 16.10.2018 / 20:25
1
answer

How to make a data annotation validator based on another field?

I'm trying to implement a validator based on another field. My domain class. [Required] public string _tipoDeControle { get; set; } [NotMapped] public TipoDeControle TipoDeControle { get { return ExtensaoDeEnumerador.ObterEnumeradorPor...
asked by 15.03.2018 / 15:23