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.

 Seam  

Basic JSF Features 

SEAM Enhancements

Seam provide an implementation for dWebSpec Equal:,target validator, with the addition of s:validateEquality.

Annotations

There is also annotations provided for various validator types; this is shown in the table below.

Validators Conversion Type Annotations
TypeValidator (On JSF platform, the converter validates and converts) string (default)
Credit card @CreditCardNumber
Email @Email;
url  
  byte These validations could be achieved using type checking methods of wrapper classes along with the @AssertFalse or @AssertTrue annotations. Specifically for integer and float like types, the following annotation is also useful: @Digits
  short
  integer
  long
  float
  double
  date
  boolean
RequiredValidator (required attribute)   @NotEmpty @NotNull
Range byte,short,integer @Range(min=, max=) @Max(value=) @Min(value=)
  long
  float
  double
Regex   @Pattern(regex="regexp", flag=) or @Patterns( {@Pattern(...)} )
MaxLength   @Length(min=, max=)
MinLength   @Length(min=, max=)
Equal   These validation could be achieved using equals method along with the @AssertFalse or @AssertTrue annotations.

Apart from those annotations that map to the dWebSpec validator types, Seams opens up the use of other validation annotations provided by the underlying Hibernate framework. These are listed below.

Annotation Description
@Size(min=, max=) check if the element size is between min and max (included)
@Past check if the date is in the past
@Future check if the date is in the future
@AssertFalse check that the method evaluates to false (useful for constraints expressed in code rather than annotations)
@AssertTrue check that the method evaluates to true (useful for constraints expressed in code rather than annotations)
@Valid perform validation recursively on the associated object. If the object is a Collection or an array, the elements are validated recursively. If the object is a Map, the value elements are validated recursively.
@Digits check whether the property is a number having up to integerDigits integer digits and fractionalDigits fractonal digits
@EAN check whether the string is a properly formated EAN or UPC-A code
Prev Next