Checking the validity of data input is a common requirement for any application that interacts with humans (and other systems), particularly business applications. I've never seen or written a data-entry application without implementing common validation rules for inputting data. LightSwitch has many ways to implement validation declaratively through the data designer as well as supporting custom code you write. Field (or property) validation is just one aspect of writing business rules in LightSwitch, but it's definitely an important one. It's your "first line of defense" in keeping user entered data consistent.

Although LightSwitch has some built-in business types and declarative validation settings, many times we need to write small snippets of code to check the format of data entered on a screen. Common things in the USA are States, ZIP codes, Social Security Numbers, UPIN, ISBN, etc. But you may also want to prevent things like numeric and symbolic values in people's or place's names or a variety of other rules based on string manipulation.

 

Read More from: Original Source