Annotation Type Numeric


@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).

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    true allows a decimal value (parsed via Double.parseDouble); false requires an integer (parsed via Integer.parseInt).
    double
    Inclusive upper bound.
    Override the default error message (NumericConstraint derives one from the bounds when blank).
    double
    Inclusive lower bound.
  • Element Details

    • decimal

      boolean decimal
      true allows a decimal value (parsed via Double.parseDouble); false requires an integer (parsed via Integer.parseInt).
      Default:
      false
    • min

      double min
      Inclusive lower bound. Default: no lower bound.
      Default:
      -1.0/0.0
    • max

      double max
      Inclusive upper bound. Default: no upper bound.
      Default:
      1.0/0.0
    • message

      String message
      Override the default error message (NumericConstraint derives one from the bounds when blank).
      Default:
      ""