1

I'm trying to validate input parameters passed in my WCF service, For example, i want to ensure that the coming string parameter is not empty and its length = 10, if not , return an error message.

I Tried to add DataAnnotations, as follows :

 public class Garantie
{
    #region fields
    [Required]
    [StringLength(10, MinimumLength = 10, ErrorMessage = "String length should be 10.")] 
    string CODE_BRANCHE;
    [Required]
    [Range(1,1, ErrorMessage = " length should be 1.")] 
    int CODE_SOUS_BRANCHE;      
    #endregion}

But this is not working. How can i fix this ?

KhadBr
  • 37
  • 9
  • Please, take a look at this answer (https://stackoverflow.com/a/12901681/772020), especially at the comments section. The article suggested there covers the issue of enforcing validation in the client by using data annotation and validators. – rdonatoiop Jan 16 '18 at 19:13

0 Answers0