Announcement

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

    Enhancement to .ds.xml validators: moreThan / lessThan (MATCHESFIELD enhancement?)

    Hi Isomorphic,

    I have a validator definiton like this in my .ds.xml:
    Code:
            <field name="FIRST_DAYS_PASSED" type="integer">
                <title><fmt:message key="firstDaysPassed" /></title>
                <validators>
                    <validator type="serverCustom">
                        <serverCondition><![CDATA[
                         #if(         "$!record.FIRST_DAYS_PASSED" != "" )
                           #set($fdp = $!record.FIRST_DAYS_PASSED)
                         #else
                           #set($fdp = $!dataSource.fetchById($record.ID).FIRST_DAYS_PASSED)
                         #end
    
                         #if(         "$!record.LAST_DAYS_PASSED" != "" )
                           #set($ldp = $!record.LAST_DAYS_PASSED)
                         #else
                           #set($ldp = $!dataSource.fetchById($record.ID).LAST_DAYS_PASSED)
                         #end
                         $fdp <= $ldp]]></serverCondition>
                        <errorMessage><fmt:message key="validatorFirstDaysPassed" /></errorMessage>
                    </validator>
                </validators>
            </field>
    I think that this closely matches what happens with ds.xml-validator MATCHESFIELD if you'd add an attribute operator to the already existing otherField.

    Most likely you would need the server stuff from above as well, as I assume that this will generate a client-only DynamicForm-only validator, after reading the client MatchesFieldValidator-docs.
    Tests whether the value for this field matches the value of some other field. The field to compare against is specified via the otherField property on the validator object (should be set to a field name). Note this validator type is only supported for items being edited within a DynamicForm - it cannot be applied to a ListGrid field.
    In my opinion this would be a valuable addition as a "from/to" field setting is quite common, also for dates.

    Best regards
    Blama
Working...
X