Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HowTo: Usage of ValidatorType.REQUIREDIF in .ds.xml

    Hi Isomorphic,

    I'm developing a BatchUpload, where the user can import main entries with child-detaildata.
    Some fields on both the masterdata/maindata and the child-detaildata are mandatory. The masterdata fields I just mark as required=true.
    I can't do that for the child-detaildata fields, as a row with just masterdata is also OK.

    So I need to validate that if one of the child-detaildata fields has data, all mandatory child-fields also have data.
    This sounds like the perfect usecase for ValidatorType.REQUIREDIF.

    Could you give an example of ValidatorType.REQUIREDIF usage in .ds.xml? The docs don't really help me.

    Questions (besides the example):
    RequiredIf type validators should be specified with an expression property set to a stringMethod, which takes three parameters
    This says three parameters, but then lists four. Also, how do I specify and write the method?

    To allow server-side enforcement, a required validator can be used instead.
    Does this mean that the validator is client-only?

    I looked it up in the LGPL and EE showcase samples, but could only find one sample, where the validator is used in Java, not in .ds.xml.

    I could easily roll this as server-custom validator in Java, but then it is serverOnly and always needs a server hit.

    Thank you & Best regards
    Blama

    #2
    Hi Isomorphic,

    after writing the post I searched the forums and hit these two threads.
    Does this mean this is (still) best solved in clientside-Java with or in addition to a serverCustom-validator on the server?

    The 2nd link shows a example with JS in .ds.xml. As I'm not using a DynamicForm but a BatchUploader/ListGrid as widget, how would the JS look here?

    Thank you & Best regards
    Blama

    Comment


      #3
      Those threads are still accurate. You can see all the variables that are available to the validator in the validator docs.

      Comment

      Working...
      X