Is there a way to validate GUID datatype?
I'm using validation attributes. http://msdn.microsoft.com/en-us/library/ee707335%28v=vs.91%29.aspx
You can use a RegularExpressionAttribute
. Here's a sample using the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
:
[RegularExpression(Pattern = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")]
You can also create a custom validation attribute, which is probably a cleaner solution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With