Netlify-cms: Nested fields in the entry editor aren't validated

Created on 29 Jun 2017  路  11Comments  路  Source: netlify/netlify-cms

Field validation only works on the top level of widgets in the entry editor, fields within objects or lists aren't validated at all.

The primary blocker here is that fields are referenced by name internally, which would then require nested fields to know the names of each ancestor field, or that their state match the nested hierarchy of the fields. Both approaches are anti-patterns.

To move forward, field state handling should be refactored to use unique id's. This will likely require a mechanism for translating the nested data in the config file to new id's at load time.

ueditocontrol-pane claimed good first issue bug high

Most helpful comment

@barthc I've reviewed and tested your code and it all looks good. I've made a few suggestions but nothing extraordinary. They don't really change the logic in your code but I tested them anyway, same result - all good from what I've tested, validation (presence and pattern) still works in "normal" fields and now also works in fields in lists and objects/objects inside lists. 馃憤

cc/ @talves

All 11 comments

I'm removing Priority tags everywhere, but this one's a very big deal.

Any idea on a timeframe on this one? Related: https://github.com/netlify/netlify-cms/pull/1873

@erquhart I've been some time away from Netlify CMS but the handling of the nested fields seems to be roughly in the same state so I reckon I remember how it's being done. Mind if I pick this up or do you folks have any larger plans for restructuring the whole nested fields situation?

@lmcorreia I've been intending a wholesale refactor that would help address this, but I'm not certain when that will happen. You're definitely welcome to take this on, and I'm happy to help if you run into any issues.

Sent with GitHawk

@erquhart Cool, I'll take a fresh look at the HOC mechanics for this and try to suggest a new approach in a PR asap

@erquhart this issue already have a PR.

@barthc #1873 - is this it?

@erquhart ^^ From the little I've dug into it, this seems to cover what can be done for the moment without getting too much into the foundations of the List and Object widgets so I'd take it as a closing point for this issue.

I'll still dig around a little more to see if I can come up with some contribution for the future refactoring but that's beyond the scope of the issue, I believe.

@lmcorreia Can you check out the PR and run tests and see if it solves the issue? That would be of great help. Would also help determine if there is any change needed that improves and work with @barthc or to discuss.

@lmcorreia Yes, that is the PR, and as @talves suggested any improvement to the PR is welcomed. At the moment, I will be updating the PR to fix conflicts and test against the new types list widget.

@barthc I've reviewed and tested your code and it all looks good. I've made a few suggestions but nothing extraordinary. They don't really change the logic in your code but I tested them anyway, same result - all good from what I've tested, validation (presence and pattern) still works in "normal" fields and now also works in fields in lists and objects/objects inside lists. 馃憤

cc/ @talves

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dur41d picture dur41d  路  3Comments

calavera picture calavera  路  3Comments

mikecrittenden picture mikecrittenden  路  3Comments

BerkeleyTrue picture BerkeleyTrue  路  3Comments

marcojakob picture marcojakob  路  3Comments