You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Intro

The Intro page provides an overview and describes the motivation for the features described below. This page explains the most important APIs and mechanisms of the property validation module provided by ExtVal. Please note that this page doesn't show all possibilities. If you have any question, please contact the community!

Dependencies

The page ExtVal Modules provides an overview about ExtVal modules and how to add them to your project.

For using the features described in this page, you have to add the core and the property validation module for the JSF version you are using.

Hello-World example

Setup

Required steps for using ExtVal:

  • Download the required ExtVal jar-files or checkout the Source Code and build it. (details)
  • Add these jar-files to your classpath (manually or via maven)
  • Use the annotations (details)

That's it!

The sample page

The sample bean

The result

Available Annotations

Simple Validation

Annotation

Description

DoubleRange

delegates to the implementation of javax.faces.validator.DoubleRangeValidator

JoinValidation

to reuse (point to) annotations of a different property (see re-use existing annotations)

Length

delegates to the implementation of javax.faces.validator.LengthValidator

LongRange

delegates to the implementation of javax.faces.validator.LongRangeValidator

Pattern

use a regular expression for validation

Required

alternative to the required attribute

SkipValidation

allows to keep validation optional. (the annotations which are afterwards and support this mechanism)

Validator

generic validator to delegate validation to an existing jsf validator e.g.: @Validator(EmailValidator.class)

JPA based validation

  • Add myfaces-extval-core-.jar and myfaces-extval-property-validation-.jar to the classpath
  • Use JPA annotations within the model (e.g.: @Column(nullable = false) -> the field is required)

That's it!

(A simple demo is available here: demo_000)

Cross-Validation

Cross-Validation

Annotation

Description

DateIs

validates if a date is equal, before or after a second date

Equals

validates if two values are equal

NotEquals

validates if two values are different

RequiredIf

validates if a value is required depending on a second value (if it is empty or not)

3rd party constraints

Since ExtVal doesn't introduce specific rules for annotations, it's possible to integrate any existing annotation.

Custom annotations

I18N support

see Internationalization

  • No labels