Changeset 39048
- Timestamp:
- 10/31/2016 05:44:56 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r39046 r39048 997 997 if ( 'array' === $args['type'] ) { 998 998 if ( ! is_array( $value ) ) { 999 return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: type name */ __( '%1$s is not of type %2$s.' ), $param, 'array' ));999 $value = preg_split( '/[\s,]+/', $value ); 1000 1000 } 1001 1001 foreach ( $value as $index => $v ) { -
trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php
r39046 r39048 104 104 $this->assertWPError( rest_validate_value_from_schema( array( true ), $schema ) ); 105 105 } 106 107 public function test_type_array_as_csv() { 108 $schema = array( 109 'type' => 'array', 110 'items' => array( 111 'type' => 'number', 112 ), 113 ); 114 $this->assertTrue( rest_validate_value_from_schema( '1', $schema ) ); 115 $this->assertTrue( rest_validate_value_from_schema( '1,2,3', $schema ) ); 116 $this->assertWPError( rest_validate_value_from_schema( 'lol', $schema ) ); 117 } 106 118 }
Note: See TracChangeset
for help on using the changeset viewer.