Home Forums Business Model Classes Validation of collection

Viewing 3 reply threads
  • Author
    Posts
    • #16334
      wyuwyu
      Participant

      Hi Team,

      I have some issue with validation of a collection which is the result of a multi picker. Validation condition is “not empty” for the picker field. The issue is when I remove all the items from the picker, validation kicks in and there is error showing on the top of the form but the field itself is not highlighted. See the attachment for detail.

      Is there anything I missed or there is a limitation on how a collection attribute should be validated.

      Thanks

       

      0
      • This topic was modified 3 years, 9 months ago by wyuwyu.
      • This topic was modified 3 years, 9 months ago by wyuwyu.
      Attachments:
      You must be logged in to view attached files.
    • #16347
      Shahzad Qureshishahzad.qureshi
      Keymaster

      Hi Wen,

      Before we can look into it, could you confirm how the validation is being done? I am assuming that its in the metadata side. Is it on the attribute itself or thru an event (which event)?

      0
      • #16358
        wyuwyu
        Participant

        Hi Shahzad, this is done on the attribute itself as we don’t want to show a popup from an event validation.

        0
    • #16378
      Shahzad Qureshishahzad.qureshi
      Keymaster

      I may have misunderstood what you are trying to accomplish. Do you mean the red asterisk doesn’t appear? if not, could you show me a screenshot from a different screen that will show what you are trying to accomplish?

      0
      • #16390
        wyuwyu
        Participant

        Hi Shahzad, I actually found the issue is not only related to collection attribute validation and the actual cause might be the fact I have some hidden attributes from the form which is validated on the model side which fails the validation and since the fields related to those hidden attributes. The overall error showing on top of the form might be coming from a hidden field.

        After I figured out the possible causes, I changed the validation code for other hidden fields and it seems to be able to indicate the correct field for the validation failure.

        0
    • #16384
      Shahzad Qureshishahzad.qureshi
      Keymaster

      You might be looking for (add-required-attr-exception) function.

      ; Adds a required attribute exception to the validation exception.
      ; @arg ve ValidationException The validation exception.
      ; @arg inst Object The Metaclass instance that has a validation exception.
      ; @arg attr Symbol The attribute that is required.
      ; @example
      ; (let ((ve ‘()))
      ;      (when (null? (person’birthTime))
      ;         (when (null? ve) (set! ve (create-validation-exception person)))
      ;         (add-required-attr-exception ve person ‘birthTime)
      ;      )
      ;    (unless (null? ve) (throw ve))
      ; )
      (define (add-required-attr-exception ve inst attr)

      0
      • #16397
        wyuwyu
        Participant

        I am not sure how this is different from just put some code to the validation part of the attribute.

        0
        • #16406
          Shahzad Qureshishahzad.qureshi
          Keymaster

          Its not different. I was simply showing you a definition of a function that can be used. You can search for this function in the code and see how it is used.

          0
Viewing 3 reply threads
  • You must be logged in to reply to this topic.