public class Constraints
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Constraints.Email
Defines a email constraint for a string field.
|
static class |
Constraints.EmailValidator
Validator for
@Email fields. |
static interface |
Constraints.Max
Defines a maximum value for a numeric field.
|
static interface |
Constraints.MaxLength
Defines a maximum length for a string field.
|
static class |
Constraints.MaxLengthValidator
Validator for
@MaxLength fields. |
static class |
Constraints.MaxValidator
Validator for
@Max fields. |
static interface |
Constraints.Min
Defines a minimum value for a numeric field.
|
static interface |
Constraints.MinLength
Defines a minimum length for a string field.
|
static class |
Constraints.MinLengthValidator
Validator for
@MinLength fields. |
static class |
Constraints.MinValidator
Validator for
@Min fields. |
static interface |
Constraints.Pattern
Defines a pattern constraint for a string field.
|
static class |
Constraints.PatternValidator
Validator for
@Pattern fields. |
static interface |
Constraints.PlayConstraintValidator<A extends java.lang.annotation.Annotation,T> |
static interface |
Constraints.PlayConstraintValidatorWithPayload<A extends java.lang.annotation.Annotation,T> |
static interface |
Constraints.Required
Defines a field as required.
|
static class |
Constraints.RequiredValidator
Validator for
@Required fields. |
static interface |
Constraints.Validatable<T> |
static interface |
Constraints.ValidatableWithPayload<T> |
static interface |
Constraints.Validate |
static interface |
Constraints.ValidatePayloadWith
Defines a custom validator.
|
static class |
Constraints.ValidatePayloadWithValidator
Validator for
@ValidatePayloadWith fields. |
static class |
Constraints.ValidateValidator |
static class |
Constraints.ValidateValidatorWithPayload |
static interface |
Constraints.ValidateWith
Defines a custom validator.
|
static interface |
Constraints.ValidateWithPayload |
static class |
Constraints.ValidateWithValidator
Validator for
@ValidateWith fields. |
static class |
Constraints.ValidationPayload |
static class |
Constraints.Validator<T>
Super-type for validators.
|
static class |
Constraints.ValidatorWithPayload<T>
Super-type for validators with a payload.
|
Constructor and Description |
---|
Constraints() |
Modifier and Type | Method and Description |
---|---|
static F.Tuple<java.lang.String,java.util.List<java.lang.Object>> |
displayableConstraint(javax.validation.metadata.ConstraintDescriptor<?> constraint)
Converts a constraint to a human-readable value.
|
static java.util.List<F.Tuple<java.lang.String,java.util.List<java.lang.Object>>> |
displayableConstraint(java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> constraints)
Converts a set of constraints to human-readable values.
|
static java.util.List<F.Tuple<java.lang.String,java.util.List<java.lang.Object>>> |
displayableConstraint(java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> constraints,
java.lang.annotation.Annotation[] orderedAnnotations)
Converts a set of constraints to human-readable values in guaranteed order.
|
static Constraints.Validator<java.lang.String> |
email()
Constructs a 'email' validator.
|
static Constraints.Validator<java.lang.Number> |
max(long value)
Constructs a 'max' validator.
|
static Constraints.Validator<java.lang.String> |
maxLength(long value)
Constructs a 'maxLength' validator.
|
static Constraints.Validator<java.lang.Number> |
min(long value)
Constructs a 'min' validator.
|
static Constraints.Validator<java.lang.String> |
minLength(long value)
Constructs a 'minLength' validator.
|
static Constraints.Validator<java.lang.String> |
pattern(java.lang.String regex)
Constructs a 'pattern' validator.
|
static Constraints.Validator<java.lang.Object> |
required()
Constructs a 'required' validator.
|
public static java.util.List<F.Tuple<java.lang.String,java.util.List<java.lang.Object>>> displayableConstraint(java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> constraints)
This method calls displayableConstraint
under the hood.
constraints
- the set of constraint descriptors.public static java.util.List<F.Tuple<java.lang.String,java.util.List<java.lang.Object>>> displayableConstraint(java.util.Set<javax.validation.metadata.ConstraintDescriptor<?>> constraints, java.lang.annotation.Annotation[] orderedAnnotations)
orderedAnnotations
parameter will be
considered. The order of the returned constraints corresponds to the order of the orderedAnnotations parameter
.constraints
- the set of constraint descriptors.orderedAnnotations
- the array of annotationspublic static F.Tuple<java.lang.String,java.util.List<java.lang.Object>> displayableConstraint(javax.validation.metadata.ConstraintDescriptor<?> constraint)
constraint
- the constraint descriptor.public static Constraints.Validator<java.lang.Object> required()
public static Constraints.Validator<java.lang.Number> min(long value)
value
- the minimum valuepublic static Constraints.Validator<java.lang.Number> max(long value)
value
- maximum valuepublic static Constraints.Validator<java.lang.String> minLength(long value)
value
- the minimum length value.public static Constraints.Validator<java.lang.String> maxLength(long value)
value
- the max lengthpublic static Constraints.Validator<java.lang.String> email()
public static Constraints.Validator<java.lang.String> pattern(java.lang.String regex)
regex
- the regular expression to match.