WooCommerce Code Reference

String_Schema extends Schema
in package

Represents a schema for a string.

See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#strings

Table of Contents

$schema  : array<string|int, mixed>
Schema definition.
default()  : static
Set the default value.
description()  : static
Set the description of the schema.
field()  : static
Set the field name and value.
formatDateTime()  : self
Set the format of the string according to DateTime.
formatEmail()  : self
Set the format of the string according to email.
formatHexColor()  : self
Set the format of the string according to Hex color.
formatIp()  : self
Set the format of the string according to IP address.
formatUri()  : self
Set the format of the string according to uri.
formatUuid()  : self
Set the format of the string according to uuid.
maxLength()  : self
Set maximum length of the string.
minLength()  : self
Set minimum length of the string.
non_nullable()  : static
Sets the schema as non-nullable.
nullable()  : static
Sets the schema as nullable.
optional()  : static
Unsets the required property.
pattern()  : self
Parameter $pattern is a regular expression without leading/trailing delimiters.
required()  : static
Sets the schema as required.
title()  : static
Set the title of the schema.
to_array()  : array<string|int, mixed>
Returns the schema as an array.
to_string()  : string
Returns the schema as a JSON string.
get_reserved_keywords()  : array<string|int, string>
Returns reserved keywords.
unset_schema_property()  : static
Unsets the schema property.
update_schema_property()  : static
Updates the schema property.
validate_pattern()  : void
Validates the regular expression pattern.

Properties

Methods

field()

Set the field name and value.

public field(string $name, mixed $value) : static
Parameters
$name : string

Name of the field.

$value : mixed

Value of the field.

Tags
throws
Exception

When the field name is reserved.

Return values
static

pattern()

Parameter $pattern is a regular expression without leading/trailing delimiters.

public pattern(string $pattern) : self

See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#pattern

Parameters
$pattern : string

Regular expression pattern.

Return values
self

update_schema_property()

Updates the schema property.

protected update_schema_property(string $name, mixed $value) : static
Parameters
$name : string

Property name.

$value : mixed

Property value.

Return values
static

validate_pattern()

Validates the regular expression pattern.

protected validate_pattern(string $pattern) : void
Parameters
$pattern : string

Regular expression pattern.

Tags
throws
Exception

When the pattern is invalid.

Return values
void