-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Nested validation bug with version 3.6.0 #7383
Comments
@fgnass could you take a look? |
Seems like the problem is here: https://github.com/decaporg/decap-cms/pull/7374/files#diff-994779730bc8166d032642e546bf8033d8ad53fe2cb05bb16d6f6e488271087dR82 Changing the validation here to
fixes this for me, but at this point it is more guesswork then a thorough solution. I'd need more testing to be sure, but I can release a patch fairly quick. Then we can add an e2e test for this and find a better solution |
+1 - this is causing many errors with my setup. |
I think I can explain why this is happening: When For objects, a similar rule applies in validatePresence(). Even if all fields inside the object are optional, the object itself will be considered invalid if empty unless Looking at the code, I would assume that the behavior we now see is the one intended by the original authors, but it was previously hidden by a bug. Manually adding |
So for example - if we have an optional button in a object block - what is the correct syntax for that? Before I had to use required: false on both my link and text attributes within my button object to make the button object "not required". |
No problem - but my question is, what is the correct way to approach this with Decap 3.6.0? |
@ryangittings We reverted it in 3.6.1, so things should work as before 3.6.0. Besides testing if the patch works, there's nothing that you need to do. |
Docs say that required field is In case #7374 will still be worked on, note that list widget behaviour is bug in any case. Either it should constantly detect empty list as invalid, or constantly as valid. |
First of all, I sincerely apologize for unintentionally introducing a breaking change. I think I was too confident due to the passing test suite – lesson learned. Regarding the proposed patch: Wouldn’t this change mean that validation rules on list widgets (like I'm curious about the best way to address this issue moving forward. Here are a few potential approaches that come to mind:
I’d love to hear your thoughts on these ideas, @martinjagodic and @demshy. |
No worries, it is not the first time that we figure out how people actually use Decap despite the docs and tests suggesting otherwise :) I tested the lists validations just now and they do seem to work with the patch, but I admit I did not dig deep enough to be able to explain why. Defaulting required to false on these widgets does seem like the most efficient way now that I think about it. I do wonder why someone would ever turn this on though, unless we also added the set/remove option from point 3 (which is actually not a bad idea, right @martinjagodic ?). |
I agree with both of you. Setting Set/remove will improve templating with Hugo because there are different types of empty objects right now. Note: we have to update the docs when this is done. PR for the current state is already open: decaporg/decap-website#104 |
In my opinion, object and list fields shouldn't have setting for required. Thinking it from UX, I would expect that object/list widget is valid if all it's children are valid. That's it. Adding extra setting to object/list widget can only confuse. Logically there's no need for it, or I missed something. Let's take a look at list widget. Currently it accepts I would propose that we remove |
Describe the bug
object or list widgets, that are nested inside parent object widget don't pass validation anymore.
Object has all fields optional, but is detected as required.
Empty list is detected as invalid. Adding and removing one item solves issue and empty list is then detected as valid.
To Reproduce
config.yml settings for fields:
try saving entry with empty optional fields
Expected behavior
Screenshots
Applicable Versions:
CMS configuration
Additional context
could be caused by #7374
The text was updated successfully, but these errors were encountered: