dWebSpec Dictionary
CONTEXT: descriptors->element->validators




All Details Standard Only Platform Only
Structured Web info and helpTechnologies
 Home Page
 Product Page
 Download Page
 Feedback
Javascript Tree Menu

Results for:

 element.validators 
Prev  Topic  Next

A space-delimited list of validators could be specified for an element. They could come in various forms that would ensure that entries conform to specific types (numeric, long, date, etc), or regular expression. They could also restrict the ranges of values, maximum or minimum length, of the enties. Others provide comprehensive validation for special fields like zip or postal code, email address, credit card number, etc.

The space -delimited list of validators entered here should be accompanied by the relevant parameters.

The standard validators for dWebSpec are listed below:

  • TypeValidator:,
  • RequiredValidator:,
  • Range:,startRange,endRange
  • Regex:,exp
  • MaxLength:,length
  • MinLength:,length
  • Equal:,target

The format is Validatior:message,variable1,variable2,variable...

message could be in this forms.

Stop
"Stop entry"  (quote needed for embedded space)
{msg.stop}  (externalized string)

variables needed are shown to the right of the validators as depicted above.

 ASP.NET  
This corresponds to ASP.NET validation controls.

The table below provides the equivalent between dWebSpec validators and the ASP.NET validators.

Validators

Conversion Type

ASP.NET Equivalents

TypeValidator

string (default)

Credit card

*

Email

*

url

*

byte

*

 

short

*

 

integer

*

 

long

*

 

float

*

 

double

*

 

date

*

 

boolean

*

RequiredValidator

 

asp:RequiredFieldValidator

Range

byte,short,integer, long

asp:RangeValidator type=Integer

 

float, double

asp:RangeValidator type=Integer

 

currency

asp:RangeValidator type=Currency

 

Date

asp:RangeValidator type=Date

string

asp:RangeValidator type=String

Regex

 

asp:RegularExpressionValidator

MaxLength

 

*

MinLength

 

*

Equal

 

asp:CompareValidator

* Although there are many validation specification types that are not covered, the presence of the custom validator (asp:CustomValidator), as well as the use of regular expression with the Regular Expression Validator would cover any of the other areas.

All validations discussed above, could be described as page scoped validations. To read about the specification scopes, go to the description of the scope attribute of this descriptor; a short introduction is provided here.

To implement object scope validation one could take advantage of the facilities provided by LINQ. Using LINQ the model is presented to the view through classes that are implemented as partials. This provides avenues for adding validation methods for the attributes of these classes. An example of this is shown below.

  Using System;
  Using System.Text.RegularExpression;

  public partial class Customer {
  		partial void OnPhoneChanging(string value) {
  			Regex phoneNumber = Regex(@"^[2-9]\d{2}-\d{3}-\d{4}$");
  			if (phoneNumber.isMatch(value) == false) {
  				throw new Exception("Not a valid phone number.");
  			}
  		}
  }

This validation becomes available on the object scope, since any element bound to the object attribute would encounter the validation.

Prev Next