AnyOfSchema.php
4 years ago
ArraySchema.php
4 years ago
BooleanSchema.php
4 years ago
IntegerSchema.php
4 years ago
NullSchema.php
4 years ago
NumberSchema.php
4 years ago
ObjectSchema.php
4 years ago
OneOfSchema.php
4 years ago
StringSchema.php
4 years ago
index.php
3 years ago
ArraySchema.php
32 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Validator\Schema; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Validator\Schema; |
| 9 | |
| 10 | // See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#arrays |
| 11 | class ArraySchema extends Schema { |
| 12 | protected $schema = [ |
| 13 | 'type' => 'array', |
| 14 | ]; |
| 15 | |
| 16 | public function items(Schema $schema): self { |
| 17 | return $this->updateSchemaProperty('items', $schema->toArray()); |
| 18 | } |
| 19 | |
| 20 | public function minItems(int $value): self { |
| 21 | return $this->updateSchemaProperty('minItems', $value); |
| 22 | } |
| 23 | |
| 24 | public function maxItems(int $value): self { |
| 25 | return $this->updateSchemaProperty('maxItems', $value); |
| 26 | } |
| 27 | |
| 28 | public function uniqueItems(): self { |
| 29 | return $this->updateSchemaProperty('uniqueItems', true); |
| 30 | } |
| 31 | } |
| 32 |