Reputation: 13124
How does RegularExpressionAttribute (System.ComponentModel.DataAnnotations) handle the translation from .NET Regular Expression pattern flavor to the javascript flavor in order to do the validations client-side?
I'm guessing that there is no translation at all, and the regular expression pattern indicated in the attribute must be compatible enough with both engines.
Thanks
Upvotes: 1
Views: 513
Reputation: 1086
Now that CodePlex has been shut down, try viewing sources on github: RegularExpressionAttributeAdapter and ModelClientValidationRegexRule.
Upvotes: 0
Reputation: 24125
Your guess is correct, the regular expression is not being translated in any way, just being directly passed to the client side. This can be easly verified by checking the source code of RegularExpressionAttributeAdapter
and ModelClientValidationRegexRule
classes.
You can check the following question for more informations about differences between C# and JavaScript Regular Expressions engines: Differences between C# and JavaScript Regular Expressions
Upvotes: 4