SharePoint 2010 introduces two new validation types for lists. One type for column validation which applies a validation check against the current column only. A second type for the list item that provides a comparison of values from more than one column.
With SharePoint 2007, Microsoft provides validation settings for columns. The most common validation is the Required validation, and for some column types a Rang validation is provided, such as Number or Currency column. Now, with SharePoint 2010, user can define a formula to validate the column; this formula cannot refer to other columns though.
The following will illustrate how to use these validations in columns.
Required validation setting can be found in most column types, and this setting applies when the user tries to create or to modify an item.
Once the Yes option is selected, content will be required for the column when user creates or edits items, and there will be an asterisk next to the column name.
If the required column is left with no input, a validation message will be displayed as follows when user tries to submit the item:
Range validation is provided for numeric columns, such as Number and Currency.
For Number and Currency columns, administrator can specify the minimum and maximum value.
Users will not be allowed to submit items if the input value is beyond the specified scope, and will receive a validation message as follows:
SharePoint 2010 extends the validation options by allowing users to define a formula to validate a column. The formula must return a true or false value and cannot refer to other fields in the list.
For Single Line of Text, if you want to input a title which begins with specified characters, you can set the formula as the following:
Fill the value begin with “order-“, it will pass the validation.
Also, the formula supports TODAY(), NOW() functions.
Another example, if Administrator wants Due Date to be after Today, he can type the following formula:
The following picture shows the result of attempting to enter an invalid date.
For some columns, SharePoint provides other validations beside the previously mentionned, such as a possibility to define the maximum length for Single Line of Text column.
When creating a Single line of text column, users can find the setting Maximum number of characters in Additional Column Settings section.
Once a value for the maximum number of characters has been specified, users cannot input the exceeding characters in the column.
For Person or Group column, administrator can constrain users to only type user or group from specified SharePoint group in the column.
This means if the user or group is not a specified SharePoint group, it will not be validated as follows:
In the above example, you require a user or group which is member of Approvers group.
Validation for item is a new feature introduced with SharePoint 2010.
A validation expression at the list level is a formula that can include any of the columns in the list and resolves as either True or False. In order to save an item in the list, this expression must resolve to True.
For example, you have two Date and time columns in Task list, Due Date and Start Date; you want to make sure users enter a bigger value in the Due Date column than the Start Date. This functionality can be achieved by using the validation setting at list level rather than column level.
To configure such a validation, follow these steps:
1. Navigate to the list where you want to add a validation, here in the Task list.
2. Enter List Settings > Validation settings.
3. Enter a formula beginning with “=”, and make sure it can evaluate to True or False.
4. Type a description for the validation formula, and save the settings.
Below is the validation message based on the above settings.