How can I break lines of an ErrorMessage from a Data Annotation?

0

I have this property and Data Annotations for it:

[Required(ErrorMessage = "Campo orbgiatório.")]
[RegularExpression("^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$", ErrorMessage = "The password must contain: \n * Pelo menos 8 caracteres; \n *Pelo menos uma letra. \n *Pelo menos um dígito. ")]
public string Password { get; set; }

I want to skip the lines of the error message between each password rule, so I'm using \ n , but it is not working. \ n only disappears and the message does not break the lines.

    
asked by anonymous 04.10.2018 / 15:02

1 answer

0

If you are viewing this validation only in a web application you can use the html tags for this:

[Required(ErrorMessage = "Campo orbgiatório.")]
[RegularExpression(
        "^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$", 
        ErrorMessage = "<b>The password must contain:</b> <br> *Pelo menos 8 caracteres; <br> *Pelo menos uma letra. <br> *Pelo menos um dígito."
    )]
public string Password { get; set; }

    
04.10.2018 / 16:58