public final class ValidationUtils extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getEmailPattern() |
static boolean |
isAtLeastZero(BigDecimal value)
Checks if the given value is greater than or equal to
BigDecimal.ZERO . |
static boolean |
isAtLeastZero(javax.money.MonetaryAmount amount)
Checks that this
MonetaryAmount contains a value that greater than or equal to zero. |
static boolean |
isAtLeastZeroOrNull(BigDecimal value)
Checks if the given value is greater than or equal to
BigDecimal.ZERO . |
static boolean |
isAtLeastZeroOrNull(javax.money.MonetaryAmount amount)
Checks that this
MonetaryAmount contains a value that greater than or equal to zero. |
static boolean |
isValidEmailAddressOrNull(String address)
Checks the given string to see if it matches the format expected of an email address.
|
static boolean |
isValidEndDate(Instant startDate,
Instant endDate)
Checks the given dates to ensure that the end date, if it exists, is after the start date.
|
static boolean |
isValidUrlStringOrNull(String url)
Checks the given string to see if it matches the format expected of a URL.
|
public static boolean isValidUrlStringOrNull(@Nullable String url)
url
- the string whose structure should be checked/
public static boolean isValidEndDate(@Nullable Instant startDate, @Nullable Instant endDate)
startDate
- the start date for an active date rangeendDate
- the end date for an active date rangepublic static boolean isAtLeastZero(@NonNull BigDecimal value)
BigDecimal.ZERO
. Useful for
validations of pricing fields where negative values are disallowed.value
- the number which should be checkedisAtLeastZeroOrNull(BigDecimal)
public static boolean isAtLeastZeroOrNull(@Nullable BigDecimal value)
BigDecimal.ZERO
. Useful for
validations of pricing fields where negative values are disallowed.value
- the number which should be checkedisAtLeastZero(BigDecimal)
public static boolean isAtLeastZeroOrNull(@Nullable javax.money.MonetaryAmount amount)
MonetaryAmount
contains a value that greater than or equal to zero.
Useful for validations of pricing fields where negative values are disallowed.amount
- public static boolean isAtLeastZero(@NonNull javax.money.MonetaryAmount amount)
MonetaryAmount
contains a value that greater than or equal to zero.
Useful for validations of pricing fields where negative values are disallowed.amount
- public static boolean isValidEmailAddressOrNull(@Nullable String address)
While this validation method is not perfect due to the complexity of the standard, this should validate the majority of requirements on email address format. See https://stackoverflow.com/questions/201323/how-to-validate-an-email-address-using-a-regular-expression/201378#201378
address
- the string whose structure should be checkedpublic static String getEmailPattern()
Copyright © 2021. All rights reserved.