com.atlassian.bamboo.utils
Class BambooValidationUtils

java.lang.Object
  extended by com.atlassian.bamboo.utils.BambooValidationUtils

public class BambooValidationUtils
extends Object

General utility methods for validation.


Constructor Summary
BambooValidationUtils()
           
 
Method Summary
static void validate(boolean validationCondition, String errorMessage)
          Validate any input data, checking if the given condition is fulfilled.
static void validateField(String fieldName, boolean validationCondition, String errorMessage)
          Validate any input field, checking if the given condition is fulfilled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BambooValidationUtils

public BambooValidationUtils()
Method Detail

validateField

public static void validateField(@NotNull
                                 String fieldName,
                                 boolean validationCondition,
                                 @NotNull
                                 String errorMessage)
                          throws WebValidationException
Validate any input field, checking if the given condition is fulfilled. If not, a WebValidationException will be thrown.

Tis method is designated to be used when verifying a specific field from any data (e.g. a form). If you want to verify general conditions not related to a specific field, use validate(boolean, String) instead.

Parameters:
fieldName - name of the field being verified
validationCondition - condition to verify
errorMessage - message to be used in the WebValidationException if the condition is not met
Throws:
WebValidationException - thrown if the given condition is not fulfilled. The exception will have one field error and no general errors. Field name and error message from method arguments will be used to construct the exception.

validate

public static void validate(boolean validationCondition,
                            @NotNull
                            String errorMessage)
                     throws WebValidationException
Validate any input data, checking if the given condition is fulfilled. If not, a WebValidationException will be thrown.

This method is designated to be used when verifying general conditions (e.g. a state of an entire form). If the data being verified is related to a specific field, use BambooValidationUtils#validateField(boolean, String, String) instead.

Parameters:
validationCondition - condition to verify
errorMessage - general error message to be used in the WebValidationException if the condition is not met
Throws:
WebValidationException - thrown if the given condition is not fulfilled. The exception will have one general error and no field errors.


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.