volto icon indicating copy to clipboard operation
volto copied to clipboard

Implementation of Validation for ObjectListWidget.

Open alexandreIFB opened this issue 7 months ago โ€ข 4 comments

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

  1. ObjectListWidget Validation:
    The ObjectListWidget was not correctly validating the schemas of its internal objects.

  2. Block Attribute Passing:
    In SearchBlockEdit.jsx, the block={block} attribute was not being properly passed to the component.

Changes

  1. 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 internalErrors property of the field's error object.
    • This allows each widget to have a flexible and customizable validation structure and logic.
  2. Structural Improvements

    • Moved ObjectListWidget to its own folder for better code organization.
    • Registered widgetValidators during the installDefaultWidgets process.
    • Fixed the passing of the block attribute in SearchBlockEdit.
    • Enabled forwarding of internalErrors within ObjectListWidget.
  3. Functional Validator for ObjectListWidget

    • Implemented a validator that checks the schema of each item in the list.
    • Utilized FormValidation to 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/

alexandreIFB avatar May 15 '25 19:05 alexandreIFB

Maybe it will help #4415

alexandreIFB avatar May 15 '25 19:05 alexandreIFB

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.

alexandreIFB avatar May 16 '25 01:05 alexandreIFB

@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.

alexandreIFB avatar May 21 '25 19:05 alexandreIFB

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. ๐Ÿงน

github-actions[bot] avatar Nov 20 '25 00:11 github-actions[bot]