On this page
rest_validate_json_schema_pattern( string $pattern, string $value ): bool
Validates if the JSON Schema pattern matches a value.
Parameters
$patternstring Required-
The pattern to match against.
$valuestring Required-
The value to check.
Return
bool True if the pattern matches the given value, false otherwise.
Source
File: wp-includes/rest-api.php. View all references
function rest_validate_json_schema_pattern( $pattern, $value ) {
$escaped_pattern = str_replace( '#', '\\#', $pattern );
return 1 === preg_match( '#' . $escaped_pattern . '#u', $value );
}
Related
Used By
| Used By | Description |
|---|---|
| rest_validate_string_value_from_schema() wp-includes/rest-api.php | Validates a string value based on a schema. |
| rest_find_matching_pattern_property_schema() wp-includes/rest-api.php | Finds the schema for a property using the patternProperties keyword. |
Changelog
| Version | Description |
|---|---|
| 5.6.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/rest_validate_json_schema_pattern