Announcement

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

    requiredIf with server-side enforcement

    I tried a this validator definition:
    Code:
            <field sqlType="varchar" sqlLength="255" name="CAUSALE_SECONDA" length="255" type="text">
                <validators>
                    <validator type="requiredIf" expression="item.form.getValue('INCLUDI_SECONDA_PARTE')"/>
                </validators>
            </field>
            <field sqlType="varchar" sqlLength="1" name="INCLUDI_SECONDA_PARTE" type="boolean" sqlStorageStrategy="singleCharTF">
            </field>
    and it's working client-side, only (verified with serverOnly="true")

    as the docs say:
    "To allow server-side enforcement, a required validator can be used instead. Conditional criteria can be specified with the applyWhen property."
    so I tried
    Code:
    validators:[
                    {type:"required", applyWhen:{INCLUDI_SECONDA_PARTE:true}}
                ]
    it works client side, but I wonder if it's validating also server side.
    if I add serverOnly:true, it seems to expect a DMI method to perform validation. How can I verify server side validation?

    #2
    For the server to be aware of the validator at all, it needs to be in the .ds.xml file, not in JS. Aside from applyWhen, there's also the serverCustom validatorType.

    You can test out server-side validation by just manually issuing a request with DataSource.addData()/updateData(), and looking at the response.

    Comment


      #3
      I know how to use a serverCustom validator, but I was looking for a "datasource only" way to express a requiredIf validator with server-side enforcement.
      Originally posted by Isomorphic
      For the server to be aware of the validator at all, it needs to be in the .ds.xml file, not in JS.
      Are you saying that it's possible to use applyWhen to express a validator which gets applied both client and server side?

      applywhen requires an AdvancedCriteria, but I don't understand how to express this in a notation which gets correctly interpreted server side and correctly translated for client.

      Comment

      Working...
      X