xh / hoist-react

🏗️ ⚛️ The XH Hoist toolkit for React
https://xh.io
Apache License 2.0
24 stars 9 forks source link

Support validation of committed records #3751

Open ghsolomon opened 2 months ago

ghsolomon commented 2 months ago

Currently, our RecordValidators only run on uncommitted records; however, we have come across a few client-apps that expect validation to run on records created via calls to loadData and updateData as well (mainly for filtering - see https://github.com/xh/hoist-react/issues/2916). A couple ideas that have been raised:

For context, a couple reasons apps may wish to validate programmatically added records:

ghsolomon commented 2 weeks ago

Bumping this since it just came up again with another project. In this case, the initial data should be considered "invalid" until the user corrects it. It is also important to keep track of the dirty state (records the user hasn't yet corrected), ability to revert records, add records, etc.

Easiest workaround at the moment is this, but obviously not a long-term solution / prone to breaking changes / etc.


Object.defineProperty(gridModel.store.validator, "uncommittedRecords", {
    get: function() {
        return this.store.allRecords;
    }
});