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

[WIP] Validate nested fields #1675

Closed
wants to merge 4 commits into from
Closed

[WIP] Validate nested fields #1675

wants to merge 4 commits into from

Conversation

erquhart
Copy link
Contributor

@erquhart erquhart commented Aug 25, 2018

Summary

Finally validate nested fields.

Functionality here is working, but we need to hunt down and address edge cases before merging. This also surfaces UI oddities that should be addressed as well.

Note that this will feel like a breaking change for a whole lot of folks, but it's technically a bug fix. Open to discussion on how best to release, but I expect we'll drop it in a feature release and apologize on Twitter. If backlash is overwhelming we can maybe add an option to disable until 3.0, but hoping we can avoid that.

Closes #467.

Dev notes, issues
This fix takes advantage of the EditorControl component, which wraps every widget, being connected directly to the Redux store as of 2.0. We're storing validation functions in Redux when each widget mounts, and removing them on unmount.

(Update: working on an alternate approach to keep state serializable.)

  • We used to validate by iterating over fields from the config file, while this fix just runs whatever validators are in the store
  • Saving the kitchen sink takes a few seconds now, worth investigating
  • Empty lists fail validation, as they should, but if you add an item and delete it no longer fails

@erquhart erquhart changed the title Validate nested fields [WIP] Validate nested fields Aug 25, 2018
@verythorough
Copy link
Contributor

verythorough commented Aug 25, 2018

Deploy preview for netlify-cms-www ready!

Built with commit 271870c

https://deploy-preview-1675--netlify-cms-www.netlify.com

hasChanged: false,
});

const entryDraftReducer = (state = Map(), action) => {
const entryDraftReducer = (state = initialState, action) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why we weren't doing this already, but if it causes bugs, we should just fix them. intialState becomes the default from the first time you open the editor, even if you go to other screens after, so we should just use it from the start.

@erquhart
Copy link
Contributor Author

erquhart commented Nov 2, 2018

Too many issues with this approach 🙄, will try a different tack in a separate PR.

@erquhart erquhart closed this Nov 2, 2018
@erquhart erquhart deleted the validate-nested-fields branch November 2, 2018 15:26
@barthc barthc mentioned this pull request Nov 12, 2018
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.

Nested fields in the entry editor aren't validated
2 participants