{"id":1307,"date":"2017-04-13T14:16:46","date_gmt":"2017-04-14T00:16:46","guid":{"rendered":"http:\/\/mymonkeydo.com\/?p=1307"},"modified":"2017-04-13T14:16:46","modified_gmt":"2017-04-14T00:16:46","slug":"wordpress-rest-api-schema-property-format-email","status":"publish","type":"post","link":"https:\/\/mymonkeydo.com\/wordpress-rest-api-schema-property-format-email\/","title":{"rendered":"WordPress REST API schema property format: email"},"content":{"rendered":"
Problem: \u00a0When setting a property type to ’email’ like so:
\n
\n$schema = array(
\n'$schema' => 'http:\/\/json-schema.org\/schema#',
\n'title' => 'user',
\n'type' => 'object',
\n'properties' => array(
\n'email' => array(
\n'description' => __( 'The optional email address for the something.' ),
\n'type' => 'string',
\n'format' => 'email',
\n'context' => array( 'edit' ),
\n'required' => false,
\n) )<\/code><\/p>\n);
\n<\/code>
\nWordPress checks if it’s an email like it should, but it does this even if an empty string is passed. \u00a0If this needs to be an optional field, the only way I see around it is to\u00a0not set the format to email.<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[2],"tags":[58,64],"yoast_head":"\n