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

Pattern CPT: Add validation for the pattern metadata #41

Merged
merged 4 commits into from
Feb 17, 2021

Conversation

ryelle
Copy link
Contributor

@ryelle ryelle commented Feb 11, 2021

This adds checks for the viewport, description, and pattern title.

See #22.

A pattern needs a title, but a draft can stay untitled, so the check for a title only applies if the pattern is or will be published. The viewport value should be between 800 - 2000 (this is arbitrary - the default is 1200 and probably shouldn't change for most patterns). The description has a max length of 360 characters. There's no minimum, since the default is an empty string, and nothing will break if there isn't a description.

To test:

Automated tests on this PR should pass.

  • Edit a published pattern
  • Try saving with an empty title
  • It should error
  • Add a title, and put too much content in the description
  • It should error (new error)

You can also test by sending requests to /wp-json/wp/v2/wporg-pattern/<ID>

@ryelle ryelle added the [Component] Pattern Directory The backend of the pattern directory: submission, management, etc label Feb 11, 2021
@ryelle ryelle self-assigned this Feb 11, 2021
@ryelle ryelle merged commit 6fc5d1b into trunk Feb 17, 2021
@ryelle ryelle deleted the add/pattern-meta-validation branch February 17, 2021 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Component] Pattern Directory The backend of the pattern directory: submission, management, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant