WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/31/2016 05:44:56 AM (3 years ago)
Author:
pento
Message:

REST API: Allow parameters defined as array to be sent as CSVs.

This allows parameters that are often handled as CSVs to be properly parsed.

Fixes #38586.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-schema-validation.php

    r39046 r39048  
    104104        $this->assertWPError( rest_validate_value_from_schema( array( true ), $schema ) );
    105105    }
     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    }
    106118}
Note: See TracChangeset for help on using the changeset viewer.