EF: data type mapping restriction

Is it possible to edit a data type error message on EF?

For example, I have to show the end user that the value entered on ID field must be integer.

public int ID { get; set; }

Thank you so much!

+3
source share
3 answers

You can use regular expression annotation to check only numbers

[RegularExpression(@"^\d+$",ErrorMessage="the value entered on ID field must be integer")]
public int MyInt { get; set; }

enter image description here

0
source

You can use Range checker:

 [Range(int.MinValue, int.MaxValue, ErrorMessageResourceName = "IDMustBeInteger",
    ErrorMessageResourceType = typeof (Resources))]
0
source

, :

  • , ( regexp - )

  • ModelBinder .

0

All Articles