class-any-of-schema.php
11 months ago
class-array-schema.php
11 months ago
class-boolean-schema.php
11 months ago
class-integer-schema.php
11 months ago
class-null-schema.php
11 months ago
class-number-schema.php
11 months ago
class-object-schema.php
11 months ago
class-one-of-schema.php
11 months ago
class-string-schema.php
11 months ago
index.php
11 months ago
class-string-schema.php
39 lines
| 1 | <?php |
| 2 | declare( strict_types = 1 ); |
| 3 | namespace Automattic\WooCommerce\EmailEditor\Validator\Schema; |
| 4 | if (!defined('ABSPATH')) exit; |
| 5 | use Automattic\WooCommerce\EmailEditor\Validator\Schema; |
| 6 | class String_Schema extends Schema { |
| 7 | protected $schema = array( |
| 8 | 'type' => 'string', |
| 9 | ); |
| 10 | public function minLength( int $value ): self { |
| 11 | return $this->update_schema_property( 'minLength', $value ); |
| 12 | } |
| 13 | public function maxLength( int $value ): self { |
| 14 | return $this->update_schema_property( 'maxLength', $value ); |
| 15 | } |
| 16 | public function pattern( string $pattern ): self { |
| 17 | $this->validate_pattern( $pattern ); |
| 18 | return $this->update_schema_property( 'pattern', $pattern ); |
| 19 | } |
| 20 | public function formatDateTime(): self { |
| 21 | return $this->update_schema_property( 'format', 'date-time' ); |
| 22 | } |
| 23 | public function formatEmail(): self { |
| 24 | return $this->update_schema_property( 'format', 'email' ); |
| 25 | } |
| 26 | public function formatHexColor(): self { |
| 27 | return $this->update_schema_property( 'format', 'hex-color' ); |
| 28 | } |
| 29 | public function formatIp(): self { |
| 30 | return $this->update_schema_property( 'format', 'ip' ); |
| 31 | } |
| 32 | public function formatUri(): self { |
| 33 | return $this->update_schema_property( 'format', 'uri' ); |
| 34 | } |
| 35 | public function formatUuid(): self { |
| 36 | return $this->update_schema_property( 'format', 'uuid' ); |
| 37 | } |
| 38 | } |
| 39 |