DecimalMin class
A constraint that requires a number above a decimal limit, or equal to it when inclusive.
Use it instead of Min when the limit has decimals, such as a price of
at least 0.01, or must be excluded (inclusive: false: more than 0).
The limit is a string ('0.01') so it is exact; values are compared
exactly like Min's, and null passes. The arguments of a field error
are [field, inclusive, value].
// Nothing is free: at least one cent.
@Introspected()
class Product {
@DecimalMin('0.01')
double price = 1;
}
Spring (Java):
class Product {
@DecimalMin("0.01")
private BigDecimal price;
}
- Inheritance
-
- Object
- Constraint
- DecimalMin
Constructors
Properties
-
attributes
→ Map<
String, Object?> -
The settings of the constraint by name, such as
{'max': 20, 'min': 0}: they fill the{max}placeholders of messages and, sorted by name, become the arguments{1},{2}, ... of field errors. Empty by default; override it when a custom constraint has settings.no setteroverride - defaultMessage → String
-
The text of a violation when message is not set, with the same
placeholders, such as
size must be between {min} and {max}.no setteroverride -
groups
→ List<
Type> -
The validation groups the constraint belongs to, such as
[OnUpdate]; it is only checked when one of them is asked for. Empty means Default.finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
- inclusive → bool
-
Whether value itself passes;
trueby default.final - message → String?
-
The text of a violation instead of defaultMessage;
nullkeeps the default.finalinherited - name → String
-
The error code of a violation, such as
NotBlank: the start of the message codes (NotBlank.signup.name, ...,NotBlank) and the Jakarta name of the constraint. Custom constraints usually return their class name.no setteroverride - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String
-
The limit, as a decimal string such as
'0.01'or'1e3'; a string that is not a number throws a ConstraintDeclarationException.final
Methods
-
appliesTo(
List< Type> requested) → bool -
Whether the constraint is checked when a validation asks for the
requestedgroups: when one of its groups is requested.inherited -
checkParameters(
) → void -
Throws a ConstraintDeclarationException when the constraint's own
settings are invalid:
Size(min: -1),min > max, a malformed regular expression. Does nothing by default.override -
interpolate(
String template) → String -
templatewith its{attribute}placeholders replaced by the values of attributes; other placeholders and${...}expressions stay, and the escapes\{,\},\$,\\become the literal characters.inherited -
interpolatedMessage(
) → String -
message, or defaultMessage, with the
{attribute}placeholders filled in; message keys and${...}expressions stay, since only the validator can resolve them.inherited -
isValid(
Object? value) → bool -
Whether
valuesatisfies the constraint; the method a custom constraint implements.override -
isValidWithContext(
Object? value, ConstraintValidatorContext context) → bool -
Whether
valuesatisfies the constraint, with access to the validationcontext; the methodBeanValidatorcalls. By default it returns isValid.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
supports(
Object value) → bool -
Whether the constraint can check a value of this type at all;
valueis nevernull.@Sizesupports strings, collections and maps, not anint.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited