Implementation of Validation for ObjectListWidget.
Hello community,
This pull request introduces improvements to the field validation system within FormValidation. The goal is to resolve existing validation issues and enhance the overall architecture for widget custom validation.
Problems Identified
-
ObjectListWidget Validation:
TheObjectListWidgetwas not correctly validating the schemas of its internal objects. -
Block Attribute Passing:
InSearchBlockEdit.jsx, theblock={block}attribute was not being properly passed to the component.
Changes
-
Custom Validation System for Widgets
- Introduced a mechanism to register validators of type
custom-validator-widget. - Errors from these validators are now stored in the
internalErrorsproperty of the field's error object. - This allows each widget to have a flexible and customizable validation structure and logic.
- Introduced a mechanism to register validators of type
-
Structural Improvements
- Moved
ObjectListWidgetto its own folder for better code organization. - Registered
widgetValidatorsduring theinstallDefaultWidgetsprocess. - Fixed the passing of the
blockattribute inSearchBlockEdit. - Enabled forwarding of
internalErrorswithinObjectListWidget.
- Moved
-
Functional Validator for ObjectListWidget
- Implemented a validator that checks the schema of each item in the list.
- Utilized
FormValidationto validate items.
The main difference compared to regular wideget validators is that with internalErrors you can use any data structure you want and handle it in the way that best suits your case.
Feedback
I'm open to suggestions, especially regarding the approach for registering validators.
Closes #7077
๐ Documentation preview ๐: https://volto--7078.org.readthedocs.build/
Maybe it will help #4415
Just a few minor docs style guide tweaks. I love PRs with docs! Thank you!
@stevepiercy Thank you for the suggestions, I have already made the indicated improvements.
@sneridagh You are right, I found a better solution by making just a few changes to what we already have to implement this custom validation for object_list, allowing internal schema validation. I reverted most changes and left a cleaner solution for this problem.
Hi There! ๐
We haven't seen any activity on this pull request in a while :sleeping:, and we want to make sure that it's still relevant. Please let us know by:
- adding a comment about what needs to be done next ๐ฌ
- updating its status and other labels ๐ท๏ธ
Otherwise close this pull request. ๐งน