Validating fuzzy logic values

The template uses the **Name** attribute for a **Field** element as it is defined in the XML schema on the server, not the **Display Name** attribute.) You can identify the field names of those fields for which you want to implement validation logic by looking at the **Binding** declarations of the **Text** properties for the **Text Box** objects defined in Edit or by examining the **View Fields** string of the **Caml Query Builder** class in the List file.

The custom validation code in this sample is executed only if the value argument passed to the Validate method is not a null or empty string.

You can, for example, use a switch statement in your implementation of this method to supply validation logic specific to various fields in the Edit form (Edit Form.xaml) of your Windows app.

For the following code example, assume that an installation of Share Point Server has a Product Orders list created from the Custom List template.

Some data types for fields in Share Point lists are associated by default with simple formatting or data validation.

If you enter an invalid URL for a field based on the Hyperlink or Picture field type in a Share Point list and attempt to save your changes, you see a message indicating that the address you entered is invalid.

If you enter anything other than a date value in a field that is bound to a Share Point field of Date and Time type in the Edit form of a Windows Phone app based on a Share Point list, you see a validation error message when the focus shifts from the Text Box control associated with the field. Validation error cue in a Windows Phone app The text box labeled "Start Time" in the Edit form is bound to a Date and Time field in the Share Point list on which this sample app is based.

These classes can be considered implementations of the View Model component of the Model-View-View Model design pattern (Figure 2).

Depending on your needs and the circumstances in which your particular Windows Phone app will be used, you likely will want to implement your own custom data-validation rules.

You can validate data entered by users of your Windows Phone app in several ways.

The list has been created with the columns and field types shown in Table 1. Product Orders list Again, for the purposes of this example, assume that the following simple validation rules are to be enforced, based on the business logic employed at the fictitious company Contoso, Ltd., for a given product ordering system: Keep in mind that the field names specified in this code sample are based on properties of the sample Product Orders list specified in Table 1.

(Notice that in the XML schema for list fields in Share Point Server, spaces in the names of fields are replaced with the string "_x0020_" for the **Name** attribute of the **Field** element that defines a given field.

Leave a Reply