org.srplib.validation
Interface Validatable<T>

All Known Implementing Classes:
DefaultValidatable

public interface Validatable<T>

Encapsulates an object which can be validated.

Validatable is unaware of UI framework and contains only validation specific logic.

Usage patterns:

  1. Extract value from to be-validated-component and wap it with Validatable implementation (e.g. DefaultValidatable).
  2. Pass resulting validatable to all associated validators
  3. Query validatable.hasErrors() method

Author:
Anton Pechinsky

Method Summary
 void addError(ValidationError error)
          Adds error to this object.
 Object getContext()
          Returns a reference to component which is being validated.
 List<ValidationError> getErrors()
          Returns validation error associated with this object.
 T getValue()
          Returns value to be validated.
 boolean hasErrors()
          Tests if this object has errors or not.
 

Method Detail

getValue

T getValue()
Returns value to be validated.

Returns:
an object representing value.

hasErrors

boolean hasErrors()
Tests if this object has errors or not.

Returns:
true if object has errors, false otherwise

addError

void addError(ValidationError error)
Adds error to this object.

Parameters:
error - ValidationError an error.

getErrors

List<ValidationError> getErrors()
Returns validation error associated with this object.

Returns:
a List of validation errors. If there are errors then empty list is returned.

getContext

Object getContext()
Returns a reference to component which is being validated.

Returns:
Object validation context


Copyright © 2014. All Rights Reserved.