0

I want to show validation errors when someone doesn't follow my validation rules (such as too few characters for a first name) or an error when they leave the field empty.

This is an example from my User.cs model class that is showing an error:

[Required(ErrorResponse= "Please do not leave first name field empty")]
[MinLength(4, ErrorResponse = "First name min length is 4")]
public string Firstname { get; set; }

The error I am getting:

Error CS0246: The type or namespace name 'ErrorResponse' could not be found (are you missing a using directive or an assembly reference?)

1 Answer 1

1

MinLength doesn't have a ErrorResponse property. I see ErrorMessage property instead.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. I thought it was just a variable that could be called anything.I tried to click the check mark to mark it as answered for some reason not letting me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.