@Retention(CLASS) @Target({FIELD})
public @interface Numeric
Requires the component value to parse as a number, optionally within a
closed range. The processor emits
com.codename1.ui.validation.NumericConstraint(decimal, min, max, message)
into the Validator returned by Binding#getValidator().
@Bind(name="ageField") @Numeric(min = 0, max = 150)
private int age;
@Bind(name="priceField") @Numeric(decimal = true, min = 0.01)
private double price;
Bounds are inclusive. Omitting min / max removes that side of the
range (the defaults are negative / positive infinity).
Methods
public abstract boolean decimal() default false | true allows a decimal value (parsed via Double.parseDouble); false requires an integer (parsed via Integer.parseInt). |
public abstract double min() default -1.0/0.0 | Inclusive lower bound. |
public abstract double max() default 1.0/0.0 | Inclusive upper bound. |
public abstract String message() default "" | Override the default error message (NumericConstraint derives one from the bounds when blank). |
Method details
decimal
public abstract boolean decimal() default falsetrue allows a decimal value (parsed via Double.parseDouble);
false requires an integer (parsed via Integer.parseInt).min
public abstract double min() default -1.0/0.0Inclusive lower bound. Default: no lower bound.
max
public abstract double max() default 1.0/0.0Inclusive upper bound. Default: no upper bound.
message
public abstract String message() default ""Override the default error message
(
NumericConstraint derives one from the bounds when blank).