Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extensible validation support in Volto forms #6181

Merged
merged 55 commits into from
Jul 30, 2024

Conversation

sneridagh
Copy link
Member

@sneridagh sneridagh commented Jul 22, 2024

Supersedes #6161
Refactored and re-document for clarity and simplicity from it.

@stevepiercy I think now it's the good one. I'm more satisfied with this one now. I will review myself again, but I think it's ready for check.

@davisagli I've refactored it a bit after talking to @robgietema in lieu of clarity and simplicity. Also reflected it in the docs too. Decisions I made, we can talk about it:

Create an API for registerUtility

I think this is much more cleaner and fixes the thing you've mentioned in the other PR, for the "trying to push the square shaped piece in the circle shape hole". Also, I took it from a previous conversation last week with @ericof but that's another story. TL;DR: it was about the convenience of having an API that does and registers things for you, whatever it is, if it's a widget or a view, or other thing where you should "touch" and manually set things in different places. This makes much more sense to me now, with the current shape.

It will also make sense in other scenarios where I think we will need such "named utilities", eg. in other frameworks, having utility helpers, like flattenToAppUrl, globally, then ask for them in a named way.

Using the format property from JSON schema specs

@robgietema pointed me out to this one, I'm using the default property for defining named validators as defined in the spec.

I still have to cleanup, will continue working polishing this a bit.


📚 Documentation preview 📚: https://volto--6181.org.readthedocs.build/

@sneridagh sneridagh requested a review from stevepiercy July 22, 2024 14:43
Copy link

netlify bot commented Jul 22, 2024

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit d50cda0
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/66a8fe6df1fbda00084b2318

@sneridagh
Copy link
Member Author

@davisagli @stevepiercy I think I went through all the suggestions, let me know if I left something!

@sneridagh sneridagh requested review from a team and ichim-david July 24, 2024 10:02
@tiberiuichim
Copy link
Contributor

Just to continue on my though on on-offs from the previous PR: I could implement a generic validator called customFunction, which reads the field definition from schema, finds a validate function in the schema and uses that for actual implementation. So I can have my "one-off" validation helper closer to the schema.

@sneridagh
Copy link
Member Author

@tiberiuichim yeah, I think you could do that already with the current implementation. However, that would only work with not serializable blocks defined in code.

Copy link
Collaborator

@stevepiercy stevepiercy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good. I am uncertain about one of my suggestions for the code sample.

docs/source/configuration/validation.md Outdated Show resolved Hide resolved
docs/source/configuration/validation.md Outdated Show resolved Hide resolved
docs/source/configuration/validation.md Outdated Show resolved Hide resolved
packages/registry/news/6161.feature Outdated Show resolved Hide resolved
packages/types/news/6161.feature Outdated Show resolved Hide resolved
@sneridagh
Copy link
Member Author

@tiberiuichim I implemented your blocksErrors prop suggestion.

Copy link
Member

@ichim-david ichim-david left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sneridagh my only concern left is regarding the type validator as we've spoken if field shouldn't also be suffixed with ? to mark it as optional as both isNumber and startEventDateRangeValidator makes no direct use of the field
https://github.com/plone/volto/pull/6181/files#diff-0fb5051092a06c331a0607394901c0217dc85e7d2f3ce393fadab348e0832b56R298

@sneridagh
Copy link
Member Author

@ichim-david done.

@sneridagh
Copy link
Member Author

Merging! Thanks to all for the effort and for having this done!

@sneridagh sneridagh merged commit 9f8c1e9 into main Jul 30, 2024
71 checks passed
@sneridagh sneridagh deleted the extensible-validation-format branch July 30, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants