org.barracudamvc.core.forms.validators
Class LinkingValidator

java.lang.Object
  extended byorg.barracudamvc.core.forms.AbstractFormValidator
      extended byorg.barracudamvc.core.forms.DefaultFormValidator
          extended byorg.barracudamvc.core.forms.validators.LinkingValidator
All Implemented Interfaces:
FormValidator

public class LinkingValidator
extends DefaultFormValidator

Ensures that if any element in a list of elements contains a non-null value that all the other elements also be non-null.

Since:
csc_110304_1
Author:
christianc@atmreports.com

Field Summary
protected  String[] fields
           
protected  String keyField
           
 
Fields inherited from class org.barracudamvc.core.forms.DefaultFormValidator
localLogger, validators
 
Constructor Summary
LinkingValidator(String[] ifields)
          Define a LinkingValidator where if any of the fields is non-null, then all the fields must be non null
LinkingValidator(String ikeyField, String[] ifields)
          Define a LinkingValidator where a group of fields are required only when a specific "key" field is not null.
 
Method Summary
protected  void _checkFields(FormMap map, String ikeyField, String[] ifields, boolean deferExceptions)
           
 void validateForm(FormMap map, boolean deferExceptions)
          Validate an entire FormMap.
 
Methods inherited from class org.barracudamvc.core.forms.DefaultFormValidator
addValidator, getValidators, removeValidator, validate, validateFormElement, validateFormElement
 
Methods inherited from class org.barracudamvc.core.forms.AbstractFormValidator
generateException, getErrorMessage, isNull, setErrorMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

keyField

protected String keyField

fields

protected String[] fields
Constructor Detail

LinkingValidator

public LinkingValidator(String[] ifields)
Define a LinkingValidator where if any of the fields is non-null, then all the fields must be non null


LinkingValidator

public LinkingValidator(String ikeyField,
                        String[] ifields)
Define a LinkingValidator where a group of fields are required only when a specific "key" field is not null.

Method Detail

validateForm

public void validateForm(FormMap map,
                         boolean deferExceptions)
                  throws ValidationException
Description copied from class: DefaultFormValidator
Validate an entire FormMap. This is the method developers should override to provide specific validation for the entire form, as opposed to validating a specific element within the form. To indicate a form is invalid, through a ValidationException, which will interrupt the validation process immediately. If you want to indicate an error, but would still like validation to continue (so that you can identify multiple errors in one validation pass) throw a DeferredValidationException instead.

Overrides:
validateForm in class DefaultFormValidator
Parameters:
map - the map to be validated
deferExceptions - do we want to deferValidation exceptions and attempt to validate all elements so that we can process all the exceptions at once
Throws:
ValidationException - if the element is not valid

_checkFields

protected void _checkFields(FormMap map,
                            String ikeyField,
                            String[] ifields,
                            boolean deferExceptions)
                     throws ValidationException
Throws:
ValidationException


Copyright © 2004 BarracudaMVC.org All Rights Reserved.