public class SizeValidatorForArray extends Object implements ConstraintValidator<Size,Object[]>
Constructor and Description |
---|
SizeValidatorForArray() |
Modifier and Type | Method and Description |
---|---|
void |
initialize(Size parameters)
Initializes the validator in preparation for
ConstraintValidator.isValid(Object, ConstraintValidatorContext) calls. |
boolean |
isValid(Object[] array,
ConstraintValidatorContext constraintValidatorContext)
Checks the number of entries in an array.
|
public void initialize(Size parameters)
ConstraintValidator
ConstraintValidator.isValid(Object, ConstraintValidatorContext)
calls.
The constraint annotation for a given constraint declaration
is passed.
This method is guaranteed to be called before any use of this instance for validation.
The default implementation is a no-op.
initialize
in interface ConstraintValidator<Size,Object[]>
parameters
- annotation instance for a given constraint declarationpublic boolean isValid(Object[] array, ConstraintValidatorContext constraintValidatorContext)
isValid
in interface ConstraintValidator<Size,Object[]>
array
- The array to validate.constraintValidatorContext
- context in which the constraint is evaluated.true
if the array is null
or the number of entries in
array
is between the specified min
and max
values (inclusive),
false
otherwise.Copyright © 2021 JBoss by Red Hat. All rights reserved.