M# Tutorials

Learn to build .NET applications with M#. Our step-by-step tutorials will get you up-to-speed rapidly.
If you already know ASP.NET and C#, you can master M# in a week or two.

String Format Validation Rule

This tutorial explains about string format validation rules available in M#. We often need to validate strings e.g. email address, postcode, internet URL etc. which require implementing regular expressions or custom string formats with server and client side validations. M# makes it very easy by providing most of the string validation formats through a property attribute “Text Pattern”.

While creating properties of an entity in M#, you can select required text pattern and M# generates the server and client side validation rule.

In the screenshot above we have selected “Email Address” as “Text Pattern” for “Email” property in the “User” entity. M# generates a validation rule in “ValidateProeprties” method in the entity class (Please read tutorial Understanding M# Validation for more details on server side validation methods).

M# also generates an ASP.NET format regular expression validator control to validate the string format as shown below