Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent false-positive in validate_callback of REST API
Related: WP-API/docs#194 ```php 'type' => 'string', 'validate_callback' => function( $should_be_date ) { return preg_match( '/^\d{4}-\d{2}-\d{2}$/u', $should_be_date ); } ``` Above validation expects the parameter should be 'YYYY-MM-DD' format, but actually any string as "valid" because `preg_match()` returns 0(falsy value) for mismatch. So, validation priority should be `is_wp_error()` -> "is true?" -> "else, invalid." Concerns: `strpos()` return 0 for match.
- Loading branch information