Is it possible to edit the error message of type of data on EF ?
For example, I've to display to the end-user that the value entered on ID's field must be integer
.
public int ID { get; set; }
Thanks a lot !!
You can use Range validator:
[Range(int.MinValue, int.MaxValue, ErrorMessageResourceName = "IDMustBeInteger",
ErrorMessageResourceType = typeof (Resources))]
You can use a regular expression annotation to validate digits only
[RegularExpression(@"^\d+$",ErrorMessage="the value entered on ID's field must be integer")]
public int MyInt { get; set; }
It seems that you have two possible solutions for your problem:
You can write client validation to check this on client (using regexp or something else)
You can use custom ModelBinder
to intercept default error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.