Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-624

Use javax.validation.constraints.Digits to specify length and scale for BigDecimal action parameters (to avoid JDO exceptions later).

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • core-1.3.0
    • core-1.4.0
    • Core
    • None

    Description

      Using the JDO @Column annotation the length/scale of properties can be specified. However, there is no capability to capture these semantics for action parameters (and the @Column annotation cannot be specified for parameters, even if we thought that were a good idea).

      With no semantics, Isis currently infers the scale of a BigDecimal from the entered input. For example, entering "123.45" will parse to a BD with scale of 2, entering "123.4567" will parse to a BD with scale of 4.

      The problem, then, is that if a BD with too large a scale is assigned to a property with a lower scale, then JDO will throw an exception.

      So this ticket is to bring in a dependency on beanval 1.1 (JSR-349) such that we can reuse the semantics of its @javax.validation.constraint.Digits annotation:

      public class ToDoItem

      @javax.jdo.annotations.Column(length=10, scale=2)
      private Cost cost;

      public void updateCost(@javax.validation.constraint.Digits(integer=8,fraction=2) BigDecimal newCost)

      { setCost(cost); }

      }

      In addition, it should be possible to add this annotation to properties too. If there is a mismatch between JDO and the Isis annotaitons, then a metamodel validation exception should be thrown.

      ~~~
      side note: ISIS-491 is to more fully integration bean validation... this is only a very small step.

      Attachments

        Activity

          People

            danhaywood Daniel Keir Haywood
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: