@FunctionalInterface public interface ParameterTypeValidator
isValid(String)
:
RequestParameter.create(Object)
to put value (maybe modified) inside
RequestParameters. The validation flow will care about set parameter nameValidationException(String)
) and/or with
ValidationException.ErrorType
(ValidationException(String, ValidationException.ErrorType)
). As for value, the
validation flow will care about setting all other ValidationException fieldsModifier and Type | Method and Description |
---|---|
static ParameterTypeValidator |
createArrayTypeValidator(ParameterTypeValidator arrayMembersValidator)
Create an array type validator
|
static ParameterTypeValidator |
createArrayTypeValidator(ParameterTypeValidator arrayMembersValidator,
String collectionFormat,
Integer maxItems,
Integer minItems)
Create an array type validator
|
static ParameterTypeValidator |
createBooleanTypeValidator(Object defaultValue)
Create a boolean type validator
|
static ParameterTypeValidator |
createDoubleTypeValidator(Boolean exclusiveMaximum,
Double maximum,
Boolean exclusiveMinimum,
Double minimum,
Double multipleOf,
Object defaultValue)
Create a new type validator for double values
|
static ParameterTypeValidator |
createDoubleTypeValidator(Double defaultValue)
Create a new type validator for double values
|
static ParameterTypeValidator |
createDoubleTypeValidator(Double maximum,
Double minimum,
Double multipleOf,
Double defaultValue)
Create a new type validator for double values
|
static ParameterTypeValidator |
createEnumTypeValidatorWithInnerValidator(List<Object> allowedValues,
ParameterTypeValidator innerValidator)
Create an enum type validator
|
static ParameterTypeValidator |
createFloatTypeValidator(Boolean exclusiveMaximum,
Double maximum,
Boolean exclusiveMinimum,
Double minimum,
Double multipleOf,
Object defaultValue)
Create a new type validator for float values
|
static ParameterTypeValidator |
createFloatTypeValidator(Double maximum,
Double minimum,
Double multipleOf,
Float defaultValue)
Create a new type validator for float values
|
static ParameterTypeValidator |
createFloatTypeValidator(Float defaultValue)
Create a new type validator for float values
|
static ParameterTypeValidator |
createIntegerTypeValidator(Boolean exclusiveMaximum,
Double maximum,
Boolean exclusiveMinimum,
Double minimum,
Double multipleOf,
Object defaultValue)
Create a new type validator for integer values
|
static ParameterTypeValidator |
createIntegerTypeValidator(Double maximum,
Double minimum,
Double multipleOf,
Integer defaultValue)
Create a new type validator for integer values
|
static ParameterTypeValidator |
createIntegerTypeValidator(Integer defaultValue)
Create a new type validator for integer values
|
static ParameterTypeValidator |
createLongTypeValidator(Boolean exclusiveMaximum,
Double maximum,
Boolean exclusiveMinimum,
Double minimum,
Double multipleOf,
Object defaultValue)
Create a new type validator for long integer values
|
static ParameterTypeValidator |
createLongTypeValidator(Double maximum,
Double minimum,
Double multipleOf,
Long defaultValue)
Create a new type validator for long integer values
|
static ParameterTypeValidator |
createLongTypeValidator(Long defaultValue)
Create a new type validator for long integer values
|
static ParameterTypeValidator |
createStringEnumTypeValidator(List<String> allowedValues)
Create an enum type validator
|
static ParameterTypeValidator |
createStringTypeValidator(Object defaultValue)
Create a new string type validator
|
static ParameterTypeValidator |
createStringTypeValidator(String pattern,
Integer minLength,
Integer maxLength,
Object defaultValue)
Create a new string type validator
|
static ParameterTypeValidator |
createStringTypeValidator(String pattern,
Object defaultValue)
Create a new string type validator
|
default Object |
getDefault()
Returns default value of parameter
|
default boolean |
hasDefault()
Returns true if this type validator has default value
|
RequestParameter |
isValid(String value)
Function that checks if parameter is valid.
|
default RequestParameter |
isValidCollection(List<String> value)
Function that checks if array of values of a specific parameter.
|
RequestParameter isValid(String value) throws ValidationException
RequestParameters
. For more info, check RequestParameter
.value
- value of parameter to testValidationException
default RequestParameter isValidCollection(List<String> value) throws ValidationException
RequestParameters
. For more info, check RequestParameter
.value
- list of values of parameter to testValidationException
default Object getDefault()
default boolean hasDefault()
static ParameterTypeValidator createIntegerTypeValidator(Integer defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createIntegerTypeValidator(Double maximum, Double minimum, Double multipleOf, Integer defaultValue)
maximum
- Maximum value. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createIntegerTypeValidator(Boolean exclusiveMaximum, Double maximum, Boolean exclusiveMinimum, Double minimum, Double multipleOf, Object defaultValue)
exclusiveMaximum
- If true, value will be mark as valid if value < maximum. If false, value will be mark as
valid if value <= maximum. The default value is false. It can be nullmaximum
- Maximum value. It can be nullexclusiveMinimum
- If true, value will be mark as valid if value > minimum. If false, value will be mark as
valid if value >= minimum. The default value is false. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default
value you have to set ParameterValidationRule.allowEmptyValue()
true. It can be
nullstatic ParameterTypeValidator createLongTypeValidator(Long defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createLongTypeValidator(Double maximum, Double minimum, Double multipleOf, Long defaultValue)
maximum
- Maximum value. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createLongTypeValidator(Boolean exclusiveMaximum, Double maximum, Boolean exclusiveMinimum, Double minimum, Double multipleOf, Object defaultValue)
exclusiveMaximum
- If true, value will be mark as valid if value < maximum. If false, value will be mark as
valid if value <= maximum. The default value is false. It can be nullmaximum
- Maximum value. It can be nullexclusiveMinimum
- If true, value will be mark as valid if value > minimum. If false, value will be mark as
valid if value >= minimum. The default value is false. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default
value you have to set ParameterValidationRule.allowEmptyValue()
true. It can be
nullstatic ParameterTypeValidator createFloatTypeValidator(Float defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createFloatTypeValidator(Double maximum, Double minimum, Double multipleOf, Float defaultValue)
maximum
- Maximum value. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createFloatTypeValidator(Boolean exclusiveMaximum, Double maximum, Boolean exclusiveMinimum, Double minimum, Double multipleOf, Object defaultValue)
exclusiveMaximum
- If true, value will be mark as valid if value < maximum. If false, value will be mark as
valid if value <= maximum. The default value is false. It can be nullmaximum
- Maximum value. It can be nullexclusiveMinimum
- If true, value will be mark as valid if value > minimum. If false, value will be mark as
valid if value >= minimum. The default value is false. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default
value you have to set ParameterValidationRule.allowEmptyValue()
true. It can be
nullstatic ParameterTypeValidator createDoubleTypeValidator(Double defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createDoubleTypeValidator(Double maximum, Double minimum, Double multipleOf, Double defaultValue)
maximum
- Maximum value. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createDoubleTypeValidator(Boolean exclusiveMaximum, Double maximum, Boolean exclusiveMinimum, Double minimum, Double multipleOf, Object defaultValue)
exclusiveMaximum
- If true, value will be mark as valid if value < maximum. If false, value will be mark as
valid if value <= maximum. The default value is false. It can be nullmaximum
- Maximum value. It can be nullexclusiveMinimum
- If true, value will be mark as valid if value > minimum. If false, value will be mark as
valid if value >= minimum. The default value is false. It can be nullminimum
- Minimum value. It can be nullmultipleOf
- Multiple of value. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default
value you have to set ParameterValidationRule.allowEmptyValue()
true. It can be
nullstatic ParameterTypeValidator createStringTypeValidator(Object defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createStringTypeValidator(String pattern, Object defaultValue)
pattern
- pattern that string have to match. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createStringTypeValidator(String pattern, Integer minLength, Integer maxLength, Object defaultValue)
pattern
- pattern that string have to match. It can be nullminLength
- Minimum length of string. It can be nullmaxLength
- Maximum length of string. It can be nulldefaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createBooleanTypeValidator(Object defaultValue)
defaultValue
- Default value that will be set if parameter is empty or not found. To apply default value
you have to set ParameterValidationRule.allowEmptyValue()
true. It can be nullstatic ParameterTypeValidator createStringEnumTypeValidator(List<String> allowedValues)
allowedValues
- allowed values. It can't be nullstatic ParameterTypeValidator createEnumTypeValidatorWithInnerValidator(List<Object> allowedValues, ParameterTypeValidator innerValidator)
allowedValues
- allowed values. It can't be nullinnerValidator
- After check if value is one of the lists, you can pass the value to an inner validator. It
can be nullstatic ParameterTypeValidator createArrayTypeValidator(ParameterTypeValidator arrayMembersValidator)
arrayMembersValidator
- Type validator that describe array items. It can't be nullstatic ParameterTypeValidator createArrayTypeValidator(ParameterTypeValidator arrayMembersValidator, String collectionFormat, Integer maxItems, Integer minItems)
arrayMembersValidator
- Type validator that describe array items. It can't be nullcollectionFormat
- String that represent a ContainerSerializationStyle. Check out
ContainerSerializationStyle
for more informations. The default value is "csv". It can be nullmaxItems
- Maximum items in array. It can be nullminItems
- Minimum items in array. It can be nullCopyright © 2023 Eclipse. All rights reserved.