public class BambooValidationUtils extends Object
Constructor and Description |
---|
BambooValidationUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
checkErrors(ErrorCollection errorCollection)
|
static boolean |
isStringRepresentingEnum(Class<? extends Enum> enumClass,
String value)
Test if string represent an enum of given type.
|
static void |
validate(boolean validationCondition,
String errorMessage)
Deprecated.
since 5.10 use
validate(boolean, Supplier) |
static void |
validate(boolean validationCondition,
Supplier<String> errorMessageSupplier)
Validate any input data, checking if the given condition is fulfilled.
|
static void |
validateField(String fieldName,
boolean validationCondition,
Supplier<String> errorMessageSupplier)
Validate any input field, checking if the given condition is fulfilled.
|
public static void validateField(@NotNull String fieldName, boolean validationCondition, @NotNull Supplier<String> errorMessageSupplier) throws WebValidationException
Validate any input field, checking if the given condition is fulfilled. If not, a WebValidationException
will be thrown.
This 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,
Supplier)
instead.
fieldName
- name of the field being verifiedvalidationCondition
- condition to verifyerrorMessageSupplier
- a supplier for a lazily evaluated error message to be used in the WebValidationException
if the condition is not met; lambda expressions are welcome
here as they allow to avoid using internationalization if it is not necessaryWebValidationException
- 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.@Deprecated public static void validate(boolean validationCondition, @NotNull String errorMessage) throws WebValidationException
validate(boolean, Supplier)
WebValidationException
public static void validate(boolean validationCondition, @NotNull Supplier<String> errorMessageSupplier) 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 validateField(String,
boolean, Supplier)
instead.
validationCondition
- condition to verifyerrorMessageSupplier
- a supplier for lazily evaluated general error message to be used in the WebValidationException
if the condition is not met; lambda expressions are welcome
here as they allow to avoid using internationalization if it is not necessaryWebValidationException
- thrown if the given condition is not fulfilled. The exception will have
one general error and no field errors.public static void checkErrors(@NotNull ErrorCollection errorCollection) throws WebValidationException
errorCollection
- an error collection (a result of any data validation)WebValidationException
- thrown if the passed error collection contains any errors. This exception will be
constructed using the error collection.Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.