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

Support imperative validation of a single action parameter argument (as well as of entire parameter args).

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • core-1.7.0
    • core-1.8.0
    • Core
    • None

    Description

      (Did this feature get removed accidentally somehow, or was I imagining it?)

      Require imperative validation on action parameters (ActionParameterValidationFacet implementing ValidatingInteractionAdvisor).

      To explain; I have an action:

          public LeaseItem newItem(
                  final LeaseItemType type,
                  final Charge charge,
                  final InvoicingFrequency invoicingFrequency,
                  final PaymentMethod paymentMethod,
                  final @Named("Start date") LocalDate startDate,
                  final ApplicationTenancy applicationTenancy) {
          }
      

      I can write supporting methods for choices and defaults for a single parameter:

          public List<ApplicationTenancy> choices5NewItem() { ... }
          public ApplicationTenancy default5NewItem() { ... }
      

      However it's not possible to validate an individual parameter arg, instead I have to validate all:

          public String validateNewItem(final LeaseItemType type,
                                         final Charge charge,
                                         final InvoicingFrequency invoicingFrequency,
                                         final PaymentMethod paymentMethod,
                                         final @Named("Start date") LocalDate startDate,
                                         final ApplicationTenancy applicationTenancy) {
              return !getApplicationTenancy().getChildren().contains(applicationTenancy)
                      ? String.format(
                          "Application tenancy '%s' is not valid for this lease (having application tenancy path '%s')",
                          applicationTenancy.getPath(),
                          getApplicationTenancyPath())
                      : null;
          }
      

      I would prefer to be able to write:

          public String validate5NewItem(final ApplicationTenancy applicationTenancy) {
              return !getApplicationTenancy().getChildren().contains(applicationTenancy)
                      ? String.format(
                          "Application tenancy '%s' is not valid for this lease (having application tenancy path '%s')",
                          applicationTenancy.getPath(),
                          getApplicationTenancyPath())
                      : null;
          }
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: