{"action":"created","issue":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/2303","repository_url":"https://api.github.com/repos/WP-API/WP-API","labels_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303/labels{/name}","comments_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303/comments","events_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303/events","html_url":"https://github.com/WP-API/WP-API/pull/2303","id":135590500,"number":2303,"title":"Fix slug and date validation for new, unpublished posts","user":{"login":"adamsilverstein","id":2676022,"avatar_url":"https://avatars.githubusercontent.com/u/2676022?v=3","gravatar_id":"","url":"https://api.github.com/users/adamsilverstein","html_url":"https://github.com/adamsilverstein","followers_url":"https://api.github.com/users/adamsilverstein/followers","following_url":"https://api.github.com/users/adamsilverstein/following{/other_user}","gists_url":"https://api.github.com/users/adamsilverstein/gists{/gist_id}","starred_url":"https://api.github.com/users/adamsilverstein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamsilverstein/subscriptions","organizations_url":"https://api.github.com/users/adamsilverstein/orgs","repos_url":"https://api.github.com/users/adamsilverstein/repos","events_url":"https://api.github.com/users/adamsilverstein/events{/privacy}","received_events_url":"https://api.github.com/users/adamsilverstein/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/WP-API/WP-API/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/WP-API/WP-API/labels/Discussion","name":"Discussion","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-23T00:38:14Z","updated_at":"2016-03-18T18:56:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/WP-API/WP-API/pulls/2303","html_url":"https://github.com/WP-API/WP-API/pull/2303","diff_url":"https://github.com/WP-API/WP-API/pull/2303.diff","patch_url":"https://github.com/WP-API/WP-API/pull/2303.patch"},"body":"When trying to save/update unpublished posts with the current validation in place, I am getting an error:\r\n\r\n> \"Invalid parameter(s): date_gmt (The date you provided is invalid.), slug (slug is not of type string)\"\r\n\r\n![screenshot](http://cl.ly/3t0d2u2N130y/TunedIn.net__random_musings_of_a_deferred_promise_2016-02-22_15-13-27.jpg)\r\n\r\nIn my testing, newly created posts (via api or wp-admin) get a `post_date_gmt` of `0000-00-00 00:00:00` - the js client can't parse that as a date and stores '`null`. Sending this value pack to the API via a PUT request results in a `rest_invalid_date` error before this patch. Checking for $value truthy before attempting to parse the date fixes the issue.\r\n\r\nNewly created, unpublished posts have a `post_name` aka `slug` that is empty. The API returns this as an empty string (`\"slug\": \"\"`) - sending an empty string back to the API before this PR results in the `rest_invalid_param` error.  I tracked this down to applying `sanitize_title` to the slug, this is somehow turning the empty string into an empty object. Changing the sanitization callback to `sanitize_key` fixes this issue and I believe thats the appropriate sanitization call to use here in any case. \r\n\r\nalso ensure the empty keys are not used in `handle_terms`\r\n"},"comment":{"url":"https://api.github.com/repos/WP-API/WP-API/issues/comments/198494063","html_url":"https://github.com/WP-API/WP-API/pull/2303#issuecomment-198494063","issue_url":"https://api.github.com/repos/WP-API/WP-API/issues/2303","id":198494063,"user":{"login":"rachelbaker","id":979807,"avatar_url":"https://avatars.githubusercontent.com/u/979807?v=3","gravatar_id":"","url":"https://api.github.com/users/rachelbaker","html_url":"https://github.com/rachelbaker","followers_url":"https://api.github.com/users/rachelbaker/followers","following_url":"https://api.github.com/users/rachelbaker/following{/other_user}","gists_url":"https://api.github.com/users/rachelbaker/gists{/gist_id}","starred_url":"https://api.github.com/users/rachelbaker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rachelbaker/subscriptions","organizations_url":"https://api.github.com/users/rachelbaker/orgs","repos_url":"https://api.github.com/users/rachelbaker/repos","events_url":"https://api.github.com/users/rachelbaker/events{/privacy}","received_events_url":"https://api.github.com/users/rachelbaker/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T18:56:06Z","updated_at":"2016-03-18T18:56:06Z","body":"> I think instead of changing the validation, we could change the return: and not return the null/blank values. Basically: if the values are not valid, the api should not return them.\r\n\r\n@adamsilverstein did you want to update this PR, or open a new one?"}}