com.vaadin.data
Interface Validator

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractStringValidator, AbstractValidator, CompositeValidator, DoubleValidator, EmailValidator, IntegerValidator, NullValidator, RegexpValidator, StringLengthValidator

public interface Validator
extends Serializable

Interface that implements a method for validating if an Object is valid or not.

Implementors of this class can be added to any Validatable implementor to verify its value.

isValid(Object) and validate(Object) can be used to check if a value is valid. isValid(Object) and validate(Object) must use the same validation logic so that iff isValid(Object) returns false, validate(Object) throws an Validator.InvalidValueException.

Validators must not have any side effects.

Since:
3.0
Version:
6.4.1
Author:
IT Mill Ltd.

Nested Class Summary
static class Validator.EmptyValueException
          A specific type of Validator.InvalidValueException that indicates that validation failed because the value was empty.
static class Validator.InvalidValueException
          Exception that is thrown by a Validator when a value is invalid.
 
Method Summary
 boolean isValid(Object value)
          Tests if the given value is valid.
 void validate(Object value)
          Checks the given value against this validator.
 

Method Detail

validate

void validate(Object value)
              throws Validator.InvalidValueException
Checks the given value against this validator. If the value is valid the method does nothing. If the value is invalid, an Validator.InvalidValueException is thrown.

Parameters:
value - the value to check
Throws:
Validator.InvalidValueException - if the value is invalid

isValid

boolean isValid(Object value)
Tests if the given value is valid. This method must be symmetric with validate(Object) so that validate(Object) throws an error iff this method returns false.

Parameters:
value - the value to check
Returns:
true if the value is valid, false otherwise.


Copyright © 2000-2010 IT Mill Ltd. All Rights Reserved.