Announcement

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

    Question about overriding DataSource.validate() on server

    I need to code some validation rules to execute on the server by overriding DataSource.validate(Map data, boolean reportMissingRequiredFields). On an update operation, will the "data" map contain all of the field values in the record, oldValues merged with any updated values? If not, how can I get access to the old values. The user may be changing the value of one field but my validation rule needs to access the value of another field that the user may or may not have also updated.

    Also, how can I access the current DSRequest being processed from within the overridden DataSource.validate() method?
    Last edited by jay.l.fisher; 22 Oct 2010, 07:41.

    #2
    Validation isn't always done in the context of a request (consider, eg, batch command line inserts of data). If you need the dsRequest, that's a good reason to put the validation logic in DataSource.execute() instead.

    Comment


      #3
      I guess I'm looking for the right spot to put our validations so that they apply regardless of the context in which the add or update occurs. DataSource.validate() seemed like the right spot. It sounds like that would work on an "add" since all of the fields to be added would be in the "data" map.

      But on an update, since the DSRequest may not have originated from the client, I assume only those fields being updated are available in the "data" map. If I need other fields in the record in order to perform the validation I would have to retrieve the record before it is updated.

      I didn't realize the was a command line interface, or some way to perform DataSource operations other than through a DSRequest. How is that done?

      Comment


        #4
        The Admin Console is one such case. Even if a dsRequest exists, oldValues may not, so a fetch of the existing values may be needed.

        Comment

        Working...
        X